diff options
author | Prem Sichanugrist <s@sikachu.com> | 2011-05-13 00:28:38 -0400 |
---|---|---|
committer | Prem Sichanugrist <s@sikachu.com> | 2011-05-13 18:25:32 -0400 |
commit | f2769ebd7eaa4bdc9aabfbff23c1ef3cbc7d4f9f (patch) | |
tree | 3b18f502faa772a3191898c9b5618441727ed752 /railties/test/generators | |
parent | a4a338167e752a4d92c64c7133ff4c975155ab7b (diff) | |
download | rails-f2769ebd7eaa4bdc9aabfbff23c1ef3cbc7d4f9f.tar.gz rails-f2769ebd7eaa4bdc9aabfbff23c1ef3cbc7d4f9f.tar.bz2 rails-f2769ebd7eaa4bdc9aabfbff23c1ef3cbc7d4f9f.zip |
Update Mailer generator to use 1.9 styled hash when run on Ruby 1.9
As always, you can run `--old-style-hash` to override that.
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/mailer_generator_test.rb | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb index f4fdc46328..bf1cfe5305 100644 --- a/railties/test/generators/mailer_generator_test.rb +++ b/railties/test/generators/mailer_generator_test.rb @@ -10,7 +10,11 @@ class MailerGeneratorTest < Rails::Generators::TestCase run_generator assert_file "app/mailers/notifier.rb" do |mailer| assert_match /class Notifier < ActionMailer::Base/, mailer - assert_match /default :from => "from@example.com"/, mailer + if RUBY_VERSION < "1.9" + assert_match /default :from => "from@example.com"/, mailer + else + assert_match /default from: "from@example.com"/, mailer + end end end @@ -73,15 +77,33 @@ class MailerGeneratorTest < Rails::Generators::TestCase assert_file "app/mailers/notifier.rb" do |mailer| assert_instance_method :foo, mailer do |foo| - assert_match /mail :to => "to@example.org"/, foo + if RUBY_VERSION < "1.9" + assert_match /mail :to => "to@example.org"/, foo + else + assert_match /mail to: "to@example.org"/, foo + end assert_match /@greeting = "Hi"/, foo end assert_instance_method :bar, mailer do |bar| - assert_match /mail :to => "to@example.org"/, bar + if RUBY_VERSION < "1.9" + assert_match /mail :to => "to@example.org"/, bar + else + assert_match /mail to: "to@example.org"/, bar + end assert_match /@greeting = "Hi"/, bar end end + end + def test_force_old_style_hash + run_generator ["notifier", "foo", "--old-style-hash"] + assert_file "app/mailers/notifier.rb" do |mailer| + assert_match /default :from => "from@example.com"/, mailer + + assert_instance_method :foo, mailer do |foo| + assert_match /mail :to => "to@example.org"/, foo + end + end end end |