diff options
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/actions_test.rb | 24 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 7 | ||||
-rw-r--r-- | railties/test/generators/mailer_generator_test.rb | 10 |
3 files changed, 29 insertions, 12 deletions
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index c6de2c1fb9..c0b88089b3 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -219,6 +219,30 @@ class ActionsTest < Rails::Generators::TestCase assert_file 'config/routes.rb', /#{Regexp.escape(route_command)}/ end + def test_route_should_add_data_with_an_new_line + run_generator + action :route, "root 'welcome#index'" + route_path = File.expand_path("config/routes.rb", destination_root) + content = File.read(route_path) + + # Remove all of the comments and blank lines from the routes file + content.gsub!(/^ \#.*\n/, '') + content.gsub!(/^\n/, '') + + File.open(route_path, "wb") { |file| file.write(content) } + assert_file "config/routes.rb", /\.routes\.draw do\n root 'welcome#index'\nend\n\z/ + + action :route, "resources :product_lines" + + routes = <<-F +Rails.application.routes.draw do + resources :product_lines + root 'welcome#index' +end +F + assert_file "config/routes.rb", routes + end + def test_readme run_generator Rails::Generators::AppGenerator.expects(:source_root).times(2).returns(destination_root) diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 4c5dd70a88..00a7932267 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -443,13 +443,6 @@ class AppGeneratorTest < Rails::Generators::TestCase end end - def test_inclusion_of_method_source - run_generator - assert_file "Gemfile" do |content| - assert_gem 'method_source' - end - end - def test_template_from_dir_pwd FileUtils.cd(Rails.root) assert_match(/It works from file!/, run_generator([destination_root, "-m", "lib/template.rb"])) diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb index 584e7a82aa..f01e8cd2d9 100644 --- a/railties/test/generators/mailer_generator_test.rb +++ b/railties/test/generators/mailer_generator_test.rb @@ -47,13 +47,13 @@ class MailerGeneratorTest < Rails::Generators::TestCase assert_match(/test "bar"/, test) end assert_file "test/mailers/previews/notifier_mailer_preview.rb" do |preview| - assert_match(/\# Preview all emails at http:\/\/localhost\:3000\/rails\/mailers\/notifier/, preview) + assert_match(/\# Preview all emails at http:\/\/localhost\:3000\/rails\/mailers\/notifier_mailer/, preview) assert_match(/class NotifierMailerPreview < ActionMailer::Preview/, preview) - assert_match(/\# Preview this email at http:\/\/localhost\:3000\/rails\/mailers\/notifier\/foo/, preview) + assert_match(/\# Preview this email at http:\/\/localhost\:3000\/rails\/mailers\/notifier_mailer\/foo/, preview) assert_instance_method :foo, preview do |foo| assert_match(/NotifierMailer.foo/, foo) end - assert_match(/\# Preview this email at http:\/\/localhost\:3000\/rails\/mailers\/notifier\/bar/, preview) + assert_match(/\# Preview this email at http:\/\/localhost\:3000\/rails\/mailers\/notifier_mailer\/bar/, preview) assert_instance_method :bar, preview do |bar| assert_match(/NotifierMailer.bar/, bar) end @@ -129,9 +129,9 @@ class MailerGeneratorTest < Rails::Generators::TestCase assert_match(/en\.farm\.animal_mailer\.moos\.subject/, mailer) end assert_file "test/mailers/previews/farm/animal_mailer_preview.rb" do |preview| - assert_match(/\# Preview all emails at http:\/\/localhost\:3000\/rails\/mailers\/farm\/animal/, preview) + assert_match(/\# Preview all emails at http:\/\/localhost\:3000\/rails\/mailers\/farm\/animal_mailer/, preview) assert_match(/class Farm::AnimalMailerPreview < ActionMailer::Preview/, preview) - assert_match(/\# Preview this email at http:\/\/localhost\:3000\/rails\/mailers\/farm\/animal\/moos/, preview) + assert_match(/\# Preview this email at http:\/\/localhost\:3000\/rails\/mailers\/farm\/animal_mailer\/moos/, preview) end assert_file "app/views/farm/animal_mailer/moos.text.erb" assert_file "app/views/farm/animal_mailer/moos.html.erb" |