diff options
Diffstat (limited to 'railties')
17 files changed, 138 insertions, 138 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 6a125685d0..e26f73ed8d 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -522,9 +522,9 @@ module Rails end initializer :append_assets_path do |app| - app.config.assets.paths.unshift *paths["vendor/assets"].existent - app.config.assets.paths.unshift *paths["lib/assets"].existent - app.config.assets.paths.unshift *paths["app/assets"].existent + app.config.assets.paths.unshift(*paths["vendor/assets"].existent) + app.config.assets.paths.unshift(*paths["lib/assets"].existent) + app.config.assets.paths.unshift(*paths["app/assets"].existent) end initializer :prepend_helpers_path do |app| diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index c323df3e95..d31a3262e3 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -278,7 +278,7 @@ module Rails say args.first.to_s unless options.quiet? else args << (self.behavior == :invoke ? :green : :red) - say_status *args + say_status(*args) end end diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index cf317eb21f..7e7f8d2d08 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -13,6 +13,7 @@ module Rails :desc => "Force using old style hash (:foo => 'bar') on Ruby >= 1.9" def initialize(args, *options) #:nodoc: + @inside_template = nil # Unfreeze name in case it's given as a frozen string args[0] = args[0].dup if args[0].is_a?(String) && args[0].frozen? super diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index 68d4c17623..597746c4aa 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -118,8 +118,8 @@ class ActionsTest < Rails::Generators::TestCase end assert_file 'config/application.rb' do |content| - assert_match /# This will be added/, content - assert_no_match /# This wont be added/, content + assert_match(/# This will be added/, content) + assert_no_match(/# This wont be added/, content) end end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index c4e944893c..42fe7a7fea 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -155,7 +155,7 @@ class AppGeneratorTest < Rails::Generators::TestCase run_generator [destination_root, "--skip-active-record"] assert_no_file "config/database.yml" assert_file "test/test_helper.rb" do |helper_content| - assert_no_match /fixtures :all/, helper_content + assert_no_match(/fixtures :all/, helper_content) end assert_file "test/performance/browsing_test.rb" end @@ -178,7 +178,7 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_match %r{^//= require jquery_ujs}, contents end assert_file 'Gemfile' do |contents| - assert_match /^gem 'jquery-rails'/, contents + assert_match(/^gem 'jquery-rails'/, contents) end end @@ -190,7 +190,7 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_match %r{^//= require prototype_ujs}, contents end assert_file 'Gemfile' do |contents| - assert_match /^gem 'prototype-rails'/, contents + assert_match(/^gem 'prototype-rails'/, contents) end end @@ -205,35 +205,35 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_inclusion_of_turn_gem_in_gemfile run_generator assert_file "Gemfile" do |contents| - assert_match /gem 'turn'/, contents unless RUBY_VERSION < '1.9.2' - assert_no_match /gem 'turn'/, contents if RUBY_VERSION < '1.9.2' + assert_match(/gem 'turn'/, contents) unless RUBY_VERSION < '1.9.2' + assert_no_match(/gem 'turn'/, contents) if RUBY_VERSION < '1.9.2' end end def test_turn_gem_is_not_included_in_gemfile_if_skipping_test_unit run_generator [destination_root, "--skip-test-unit"] assert_file "Gemfile" do |contents| - assert_no_match /gem 'turn'/, contents unless RUBY_VERSION < '1.9.2' + assert_no_match(/gem 'turn'/, contents) unless RUBY_VERSION < '1.9.2' end end def test_inclusion_of_ruby_debug run_generator assert_file "Gemfile" do |contents| - assert_match /gem 'ruby-debug'/, contents if RUBY_VERSION < '1.9' + assert_match(/gem 'ruby-debug'/, contents) if RUBY_VERSION < '1.9' end end def test_inclusion_of_ruby_debug19_if_ruby19 run_generator assert_file "Gemfile" do |contents| - assert_match /gem 'ruby-debug19', :require => 'ruby-debug'/, contents unless RUBY_VERSION < '1.9' + assert_match(/gem 'ruby-debug19', :require => 'ruby-debug'/, contents) unless RUBY_VERSION < '1.9' 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"]) + assert_match(/It works from file!/, run_generator([destination_root, "-m", "lib/template.rb"])) end def test_usage_read_from_file @@ -243,7 +243,7 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_default_usage File.expects(:exist?).returns(false) - assert_match /Create rails files for app generator/, Rails::Generators::AppGenerator.desc + assert_match(/Create rails files for app generator/, Rails::Generators::AppGenerator.desc) end def test_default_namespace @@ -270,9 +270,9 @@ class AppGeneratorTest < Rails::Generators::TestCase run_generator [destination_root] assert_file "config/initializers/session_store.rb" do |file| if RUBY_VERSION < "1.9" - assert_match /config.session_store :cookie_store, :key => '_.+_session'/, file + assert_match(/config.session_store :cookie_store, :key => '_.+_session'/, file) else - assert_match /config.session_store :cookie_store, key: '_.+_session'/, file + assert_match(/config.session_store :cookie_store, key: '_.+_session'/, file) end end end @@ -280,7 +280,7 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_force_old_style_hash run_generator [destination_root, "--old-style-hash"] assert_file "config/initializers/session_store.rb" do |file| - assert_match /config.session_store :cookie_store, :key => '_.+_session'/, file + assert_match(/config.session_store :cookie_store, :key => '_.+_session'/, file) end end diff --git a/railties/test/generators/controller_generator_test.rb b/railties/test/generators/controller_generator_test.rb index 2dfc91c683..46533b70be 100644 --- a/railties/test/generators/controller_generator_test.rb +++ b/railties/test/generators/controller_generator_test.rb @@ -9,7 +9,7 @@ class ControllerGeneratorTest < Rails::Generators::TestCase def test_help_does_not_show_invoked_generators_options_if_they_already_exist content = run_generator ["--help"] - assert_no_match /Helper options\:/, content + assert_no_match(/Helper options\:/, content) end def test_controller_skeleton_is_created @@ -20,7 +20,7 @@ class ControllerGeneratorTest < Rails::Generators::TestCase def test_check_class_collision Object.send :const_set, :ObjectController, Class.new content = capture(:stderr){ run_generator ["object"] } - assert_match /The name 'ObjectController' is either already used in your application or reserved/, content + assert_match(/The name 'ObjectController' is either already used in your application or reserved/, content) ensure Object.send :remove_const, :ObjectController end diff --git a/railties/test/generators/helper_generator_test.rb b/railties/test/generators/helper_generator_test.rb index f0bfebd57f..8da3aa61a4 100644 --- a/railties/test/generators/helper_generator_test.rb +++ b/railties/test/generators/helper_generator_test.rb @@ -20,17 +20,17 @@ class HelperGeneratorTest < Rails::Generators::TestCase def test_logs_if_the_test_framework_cannot_be_found content = run_generator ["admin", "--test-framework=rspec"] - assert_match /rspec \[not found\]/, content + assert_match(/rspec \[not found\]/, content) end def test_check_class_collision content = capture(:stderr){ run_generator ["object"] } - assert_match /The name 'ObjectHelper' is either already used in your application or reserved/, content + assert_match(/The name 'ObjectHelper' is either already used in your application or reserved/, content) end def test_check_class_collision_on_tests content = capture(:stderr){ run_generator ["another_object"] } - assert_match /The name 'AnotherObjectHelperTest' is either already used in your application or reserved/, content + assert_match(/The name 'AnotherObjectHelperTest' is either already used in your application or reserved/, content) end def test_namespaced_and_not_namespaced_helpers diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb index bf1cfe5305..139d6b1421 100644 --- a/railties/test/generators/mailer_generator_test.rb +++ b/railties/test/generators/mailer_generator_test.rb @@ -9,11 +9,11 @@ class MailerGeneratorTest < Rails::Generators::TestCase def test_mailer_skeleton_is_created run_generator assert_file "app/mailers/notifier.rb" do |mailer| - assert_match /class Notifier < ActionMailer::Base/, mailer + assert_match(/class Notifier < ActionMailer::Base/, mailer) if RUBY_VERSION < "1.9" - assert_match /default :from => "from@example.com"/, mailer + assert_match(/default :from => "from@example.com"/, mailer) else - assert_match /default from: "from@example.com"/, mailer + assert_match(/default from: "from@example.com"/, mailer) end end end @@ -21,35 +21,35 @@ class MailerGeneratorTest < Rails::Generators::TestCase def test_mailer_with_i18n_helper run_generator assert_file "app/mailers/notifier.rb" do |mailer| - assert_match /en\.notifier\.foo\.subject/, mailer - assert_match /en\.notifier\.bar\.subject/, mailer + assert_match(/en\.notifier\.foo\.subject/, mailer) + assert_match(/en\.notifier\.bar\.subject/, mailer) end end def test_check_class_collision content = capture(:stderr){ run_generator ["object"] } - assert_match /The name 'Object' is either already used in your application or reserved/, content + assert_match(/The name 'Object' is either already used in your application or reserved/, content) end def test_invokes_default_test_framework run_generator assert_file "test/functional/notifier_test.rb" do |test| - assert_match /class NotifierTest < ActionMailer::TestCase/, test - assert_match /test "foo"/, test - assert_match /test "bar"/, test + assert_match(/class NotifierTest < ActionMailer::TestCase/, test) + assert_match(/test "foo"/, test) + assert_match(/test "bar"/, test) end end def test_invokes_default_template_engine run_generator assert_file "app/views/notifier/foo.text.erb" do |view| - assert_match %r(app/views/notifier/foo\.text\.erb), view - assert_match /<%= @greeting %>/, view + assert_match(%r(app/views/notifier/foo\.text\.erb), view) + assert_match(/<%= @greeting %>/, view) end assert_file "app/views/notifier/bar.text.erb" do |view| - assert_match %r(app/views/notifier/bar\.text\.erb), view - assert_match /<%= @greeting %>/, view + assert_match(%r(app/views/notifier/bar\.text\.erb), view) + assert_match(/<%= @greeting %>/, view) end end @@ -60,14 +60,14 @@ class MailerGeneratorTest < Rails::Generators::TestCase def test_logs_if_the_template_engine_cannot_be_found content = run_generator ["notifier", "foo", "bar", "--template-engine=haml"] - assert_match /haml \[not found\]/, content + assert_match(/haml \[not found\]/, content) end def test_mailer_with_namedspaced_mailer run_generator ["Farm::Animal", "moos"] assert_file "app/mailers/farm/animal.rb" do |mailer| - assert_match /class Farm::Animal < ActionMailer::Base/, mailer - assert_match /en\.farm\.animal\.moos\.subject/, mailer + assert_match(/class Farm::Animal < ActionMailer::Base/, mailer) + assert_match(/en\.farm\.animal\.moos\.subject/, mailer) end assert_file "app/views/farm/animal/moos.text.erb" end @@ -78,20 +78,20 @@ class MailerGeneratorTest < Rails::Generators::TestCase assert_file "app/mailers/notifier.rb" do |mailer| assert_instance_method :foo, mailer do |foo| if RUBY_VERSION < "1.9" - assert_match /mail :to => "to@example.org"/, foo + assert_match(/mail :to => "to@example.org"/, foo) else - assert_match /mail to: "to@example.org"/, foo + assert_match(/mail to: "to@example.org"/, foo) end - assert_match /@greeting = "Hi"/, foo + assert_match(/@greeting = "Hi"/, foo) end assert_instance_method :bar, mailer do |bar| if RUBY_VERSION < "1.9" - assert_match /mail :to => "to@example.org"/, bar + assert_match(/mail :to => "to@example.org"/, bar) else - assert_match /mail to: "to@example.org"/, bar + assert_match(/mail to: "to@example.org"/, bar) end - assert_match /@greeting = "Hi"/, bar + assert_match(/@greeting = "Hi"/, bar) end end end @@ -99,10 +99,10 @@ class MailerGeneratorTest < Rails::Generators::TestCase 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_match(/default :from => "from@example.com"/, mailer) assert_instance_method :foo, mailer do |foo| - assert_match /mail :to => "to@example.org"/, foo + assert_match(/mail :to => "to@example.org"/, foo) end end end diff --git a/railties/test/generators/migration_generator_test.rb b/railties/test/generators/migration_generator_test.rb index 6eecfc8e2e..337257df7d 100644 --- a/railties/test/generators/migration_generator_test.rb +++ b/railties/test/generators/migration_generator_test.rb @@ -35,8 +35,8 @@ class MigrationGeneratorTest < Rails::Generators::TestCase assert_migration "db/migrate/#{migration}.rb" do |content| assert_method :change, content do |up| - assert_match /add_column :posts, :title, :string/, up - assert_match /add_column :posts, :body, :text/, up + assert_match(/add_column :posts, :title, :string/, up) + assert_match(/add_column :posts, :body, :text/, up) end end end @@ -47,13 +47,13 @@ class MigrationGeneratorTest < Rails::Generators::TestCase assert_migration "db/migrate/#{migration}.rb" do |content| assert_method :up, content do |up| - assert_match /remove_column :posts, :title/, up - assert_match /remove_column :posts, :body/, up + assert_match(/remove_column :posts, :title/, up) + assert_match(/remove_column :posts, :body/, up) end assert_method :down, content do |down| - assert_match /add_column :posts, :title, :string/, down - assert_match /add_column :posts, :body, :text/, down + assert_match(/add_column :posts, :title, :string/, down) + assert_match(/add_column :posts, :body, :text/, down) end end end @@ -64,11 +64,11 @@ class MigrationGeneratorTest < Rails::Generators::TestCase assert_migration "db/migrate/#{migration}.rb" do |content| assert_method :up, content do |up| - assert_match /^\s*$/, up + assert_match(/^\s*$/, up) end assert_method :down, content do |down| - assert_match /^\s*$/, down + assert_match(/^\s*$/, down) end end end diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb index 3d773b4134..8c5ba9926b 100644 --- a/railties/test/generators/model_generator_test.rb +++ b/railties/test/generators/model_generator_test.rb @@ -7,14 +7,14 @@ class ModelGeneratorTest < Rails::Generators::TestCase def test_help_shows_invoked_generators_options content = run_generator ["--help"] - assert_match /ActiveRecord options:/, content - assert_match /TestUnit options:/, content + assert_match(/ActiveRecord options:/, content) + assert_match(/TestUnit options:/, content) end def test_model_with_missing_attribute_type content = capture(:stderr) { run_generator ["post", "title:string", "body"] } - assert_match /Missing type for attribute 'body'/, content - assert_match /Example: 'body:string' where string is the type/, content + assert_match(/Missing type for attribute 'body'/, content) + assert_match(/Example: 'body:string' where string is the type/, content) end def test_invokes_default_orm @@ -100,9 +100,9 @@ class ModelGeneratorTest < Rails::Generators::TestCase assert_migration "db/migrate/create_products.rb" do |m| assert_method :change, m do |up| - assert_match /create_table :products/, up - assert_match /t\.string :name/, up - assert_match /t\.integer :supplier_id/, up + assert_match(/create_table :products/, up) + assert_match(/t\.string :name/, up) + assert_match(/t\.integer :supplier_id/, up) end end end @@ -138,7 +138,7 @@ class ModelGeneratorTest < Rails::Generators::TestCase assert_migration "db/migrate/create_accounts.rb" do |m| assert_method :change, m do |up| - assert_no_match /t.timestamps/, up + assert_no_match(/t.timestamps/, up) end end end @@ -164,7 +164,7 @@ class ModelGeneratorTest < Rails::Generators::TestCase def test_migration_error_is_not_shown_on_revoke run_generator error = capture(:stderr){ run_generator ["Account"], :behavior => :revoke } - assert_no_match /Another migration is already named create_accounts/, error + assert_no_match(/Another migration is already named create_accounts/, error) end def test_migration_is_removed_on_revoke @@ -177,7 +177,7 @@ class ModelGeneratorTest < Rails::Generators::TestCase run_generator old_migration = Dir["#{destination_root}/db/migrate/*_create_accounts.rb"].first error = capture(:stderr) { run_generator ["Account", "--force"] } - assert_no_match /Another migration is already named create_accounts/, error + assert_no_match(/Another migration is already named create_accounts/, error) assert_no_file old_migration assert_migration 'db/migrate/create_accounts.rb' end @@ -195,13 +195,13 @@ class ModelGeneratorTest < Rails::Generators::TestCase def test_fixture_is_skipped_if_fixture_replacement_is_given content = run_generator ["account", "-r", "factory_girl"] - assert_match /factory_girl \[not found\]/, content + assert_match(/factory_girl \[not found\]/, content) assert_no_file "test/fixtures/accounts.yml" end def test_check_class_collision content = capture(:stderr){ run_generator ["object"] } - assert_match /The name 'Object' is either already used in your application or reserved/, content + assert_match(/The name 'Object' is either already used in your application or reserved/, content) end def test_index_is_added_for_belongs_to_association @@ -209,7 +209,7 @@ class ModelGeneratorTest < Rails::Generators::TestCase assert_migration "db/migrate/create_accounts.rb" do |m| assert_method :change, m do |up| - assert_match /add_index/, up + assert_match(/add_index/, up) end end end @@ -219,7 +219,7 @@ class ModelGeneratorTest < Rails::Generators::TestCase assert_migration "db/migrate/create_accounts.rb" do |m| assert_method :change, m do |up| - assert_match /add_index/, up + assert_match(/add_index/, up) end end end @@ -229,7 +229,7 @@ class ModelGeneratorTest < Rails::Generators::TestCase assert_migration "db/migrate/create_accounts.rb" do |m| assert_method :change, m do |up| - assert_no_match /add_index/, up + assert_no_match(/add_index/, up) end end end @@ -239,9 +239,8 @@ class ModelGeneratorTest < Rails::Generators::TestCase assert_migration "db/migrate/create_accounts.rb" do |m| assert_method :change, m do |up| - assert_no_match /add_index/, up + assert_no_match(/add_index/, up) end end end - end diff --git a/railties/test/generators/namespaced_generators_test.rb b/railties/test/generators/namespaced_generators_test.rb index 38f024f061..6f8a9b4280 100644 --- a/railties/test/generators/namespaced_generators_test.rb +++ b/railties/test/generators/namespaced_generators_test.rb @@ -161,12 +161,12 @@ class NamespacedMailerGeneratorTest < NamespacedGeneratorTestCase def test_mailer_skeleton_is_created run_generator assert_file "app/mailers/test_app/notifier.rb" do |mailer| - assert_match /module TestApp/, mailer - assert_match /class Notifier < ActionMailer::Base/, mailer + assert_match(/module TestApp/, mailer) + assert_match(/class Notifier < ActionMailer::Base/, mailer) if RUBY_VERSION < "1.9" - assert_match /default :from => "from@example.com"/, mailer + assert_match(/default :from => "from@example.com"/, mailer) else - assert_match /default from: "from@example.com"/, mailer + assert_match(/default from: "from@example.com"/, mailer) end end end @@ -174,31 +174,31 @@ class NamespacedMailerGeneratorTest < NamespacedGeneratorTestCase def test_mailer_with_i18n_helper run_generator assert_file "app/mailers/test_app/notifier.rb" do |mailer| - assert_match /en\.notifier\.foo\.subject/, mailer - assert_match /en\.notifier\.bar\.subject/, mailer + assert_match(/en\.notifier\.foo\.subject/, mailer) + assert_match(/en\.notifier\.bar\.subject/, mailer) end end def test_invokes_default_test_framework run_generator assert_file "test/functional/test_app/notifier_test.rb" do |test| - assert_match /module TestApp/, test - assert_match /class NotifierTest < ActionMailer::TestCase/, test - assert_match /test "foo"/, test - assert_match /test "bar"/, test + assert_match(/module TestApp/, test) + assert_match(/class NotifierTest < ActionMailer::TestCase/, test) + assert_match(/test "foo"/, test) + assert_match(/test "bar"/, test) end end def test_invokes_default_template_engine run_generator assert_file "app/views/test_app/notifier/foo.text.erb" do |view| - assert_match %r(app/views/test_app/notifier/foo\.text\.erb), view - assert_match /<%= @greeting %>/, view + assert_match(%r(app/views/test_app/notifier/foo\.text\.erb), view) + assert_match(/<%= @greeting %>/, view) end assert_file "app/views/test_app/notifier/bar.text.erb" do |view| - assert_match %r(app/views/test_app/notifier/bar\.text\.erb), view - assert_match /<%= @greeting %>/, view + assert_match(%r(app/views/test_app/notifier/bar\.text\.erb), view) + assert_match(/<%= @greeting %>/, view) end end diff --git a/railties/test/generators/observer_generator_test.rb b/railties/test/generators/observer_generator_test.rb index 45fe8dfbd3..afcee0a2dc 100644 --- a/railties/test/generators/observer_generator_test.rb +++ b/railties/test/generators/observer_generator_test.rb @@ -22,6 +22,6 @@ class ObserverGeneratorTest < Rails::Generators::TestCase def test_logs_if_the_test_framework_cannot_be_found content = run_generator ["account", "--test-framework=rspec"] - assert_match /rspec \[not found\]/, content + assert_match(/rspec \[not found\]/, content) end end diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb index e6686a6af4..5c0774ddbd 100644 --- a/railties/test/generators/plugin_generator_test.rb +++ b/railties/test/generators/plugin_generator_test.rb @@ -32,7 +32,7 @@ class PluginGeneratorTest < Rails::Generators::TestCase def test_check_class_collision content = capture(:stderr){ run_generator ["object"] } - assert_match /The name 'Object' is either already used in your application or reserved/, content + assert_match(/The name 'Object' is either already used in your application or reserved/, content) end def test_invokes_default_test_framework @@ -44,7 +44,7 @@ class PluginGeneratorTest < Rails::Generators::TestCase def test_logs_if_the_test_framework_cannot_be_found content = nil silence(:stderr) { content = run_generator ["plugin_fu", "--test-framework=rspec"] } - assert_match /rspec \[not found\]/, content + assert_match(/rspec \[not found\]/, content) end def test_creates_tasks_if_required @@ -66,6 +66,6 @@ class PluginGeneratorTest < Rails::Generators::TestCase def test_deprecation output = capture(:stderr) { run_generator } - assert_match /Plugin generator is deprecated, please use 'rails plugin new' command to generate plugin structure./, output + assert_match(/Plugin generator is deprecated, please use 'rails plugin new' command to generate plugin structure./, output) end end diff --git a/railties/test/generators/resource_generator_test.rb b/railties/test/generators/resource_generator_test.rb index 71b3619351..73804dae45 100644 --- a/railties/test/generators/resource_generator_test.rb +++ b/railties/test/generators/resource_generator_test.rb @@ -9,8 +9,8 @@ class ResourceGeneratorTest < Rails::Generators::TestCase def test_help_with_inherited_options content = run_generator ["--help"] - assert_match /ActiveRecord options:/, content - assert_match /TestUnit options:/, content + assert_match(/ActiveRecord options:/, content) + assert_match(/TestUnit options:/, content) end def test_files_from_inherited_invocation @@ -55,7 +55,7 @@ class ResourceGeneratorTest < Rails::Generators::TestCase run_generator assert_file "config/routes.rb" do |route| - assert_match /resources :accounts$/, route + assert_match(/resources :accounts$/, route) end end @@ -63,19 +63,19 @@ class ResourceGeneratorTest < Rails::Generators::TestCase content = run_generator ["accounts".freeze] assert_file "app/models/account.rb", /class Account < ActiveRecord::Base/ assert_file "test/unit/account_test.rb", /class AccountTest/ - assert_match /Plural version of the model detected, using singularized version. Override with --force-plural./, content + assert_match(/Plural version of the model detected, using singularized version. Override with --force-plural./, content) end def test_plural_names_can_be_forced content = run_generator ["accounts", "--force-plural"] assert_file "app/models/accounts.rb", /class Accounts < ActiveRecord::Base/ assert_file "test/unit/accounts_test.rb", /class AccountsTest/ - assert_no_match /Plural version of the model detected/, content + assert_no_match(/Plural version of the model detected/, content) end def test_mass_nouns_do_not_throw_warnings content = run_generator ["sheep".freeze] - assert_no_match /Plural version of the model detected/, content + assert_no_match(/Plural version of the model detected/, content) end def test_route_is_removed_on_revoke @@ -83,7 +83,7 @@ class ResourceGeneratorTest < Rails::Generators::TestCase run_generator ["account"], :behavior => :revoke assert_file "config/routes.rb" do |route| - assert_no_match /resources :accounts$/, route + assert_no_match(/resources :accounts$/, route) end end end diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb index c7f45a807d..65b30b9fbd 100644 --- a/railties/test/generators/scaffold_controller_generator_test.rb +++ b/railties/test/generators/scaffold_controller_generator_test.rb @@ -14,39 +14,39 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase run_generator assert_file "app/controllers/users_controller.rb" do |content| - assert_match /class UsersController < ApplicationController/, content + assert_match(/class UsersController < ApplicationController/, content) assert_instance_method :index, content do |m| - assert_match /@users = User\.all/, m + assert_match(/@users = User\.all/, m) end assert_instance_method :show, content do |m| - assert_match /@user = User\.find\(params\[:id\]\)/, m + assert_match(/@user = User\.find\(params\[:id\]\)/, m) end assert_instance_method :new, content do |m| - assert_match /@user = User\.new/, m + assert_match(/@user = User\.new/, m) end assert_instance_method :edit, content do |m| - assert_match /@user = User\.find\(params\[:id\]\)/, m + assert_match(/@user = User\.find\(params\[:id\]\)/, m) end assert_instance_method :create, content do |m| - assert_match /@user = User\.new\(params\[:user\]\)/, m - assert_match /@user\.save/, m - assert_match /@user\.errors/, m + assert_match(/@user = User\.new\(params\[:user\]\)/, m) + assert_match(/@user\.save/, m) + assert_match(/@user\.errors/, m) end assert_instance_method :update, content do |m| - assert_match /@user = User\.find\(params\[:id\]\)/, m - assert_match /@user\.update_attributes\(params\[:user\]\)/, m - assert_match /@user\.errors/, m + assert_match(/@user = User\.find\(params\[:id\]\)/, m) + assert_match(/@user\.update_attributes\(params\[:user\]\)/, m) + assert_match(/@user\.errors/, m) end assert_instance_method :destroy, content do |m| - assert_match /@user = User\.find\(params\[:id\]\)/, m - assert_match /@user\.destroy/, m + assert_match(/@user = User\.find\(params\[:id\]\)/, m) + assert_match(/@user\.destroy/, m) end end end @@ -73,8 +73,8 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase run_generator assert_file "test/functional/users_controller_test.rb" do |content| - assert_match /class UsersControllerTest < ActionController::TestCase/, content - assert_match /test "should get index"/, content + assert_match(/class UsersControllerTest < ActionController::TestCase/, content) + assert_match(/test "should get index"/, content) end end @@ -93,10 +93,10 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase run_generator ["User", "--orm=unknown"] assert_file "app/controllers/users_controller.rb" do |content| - assert_match /class UsersController < ApplicationController/, content + assert_match(/class UsersController < ApplicationController/, content) assert_instance_method :index, content do |m| - assert_match /@users = User\.all/, m + assert_match(/@users = User\.all/, m) end end end @@ -112,11 +112,11 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase run_generator ["User", "--orm=unknown"] assert_file "app/controllers/users_controller.rb" do |content| - assert_match /class UsersController < ApplicationController/, content + assert_match(/class UsersController < ApplicationController/, content) assert_instance_method :index, content do |m| - assert_match /@users = User\.find\(:all\)/, m - assert_no_match /@users = User\.all/, m + assert_match(/@users = User\.find\(:all\)/, m) + assert_no_match(/@users = User\.all/, m) end end ensure @@ -127,9 +127,9 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase run_generator assert_file "app/controllers/users_controller.rb" do |content| if RUBY_VERSION < "1.9" - assert_match /\{ render :action => "new" \}/, content + assert_match(/\{ render :action => "new" \}/, content) else - assert_match /\{ render action: "new" \}/, content + assert_match(/\{ render action: "new" \}/, content) end end end @@ -137,7 +137,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase def test_force_old_style_hash run_generator ["User", "--old-style-hash"] assert_file "app/controllers/users_controller.rb" do |content| - assert_match /\{ render :action => "new" \}/, content + assert_match(/\{ render :action => "new" \}/, content) end end end diff --git a/railties/test/generators/session_migration_generator_test.rb b/railties/test/generators/session_migration_generator_test.rb index 9fee948d7c..b590047ff0 100644 --- a/railties/test/generators/session_migration_generator_test.rb +++ b/railties/test/generators/session_migration_generator_test.rb @@ -18,8 +18,8 @@ class SessionMigrationGeneratorTest < Rails::Generators::TestCase ActiveRecord::SessionStore::Session.table_name = "custom_table_name" run_generator assert_migration "db/migrate/add_sessions_table.rb" do |migration| - assert_match /class AddSessionsTable < ActiveRecord::Migration/, migration - assert_match /create_table :custom_table_name/, migration + assert_match(/class AddSessionsTable < ActiveRecord::Migration/, migration) + assert_match(/create_table :custom_table_name/, migration) end ensure ActiveRecord::SessionStore::Session.table_name = "sessions" diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb index 99c9d790eb..1264ac7764 100644 --- a/railties/test/generators_test.rb +++ b/railties/test/generators_test.rb @@ -28,7 +28,7 @@ class GeneratorsTest < Rails::Generators::TestCase def test_help_when_a_generator_with_required_arguments_is_invoked_without_arguments output = capture(:stdout){ Rails::Generators.invoke :model, [] } - assert_match /Description:/, output + assert_match(/Description:/, output) end def test_should_give_higher_preference_to_rails_generators @@ -90,8 +90,8 @@ class GeneratorsTest < Rails::Generators::TestCase def test_find_by_namespace_show_warning_if_generator_cant_be_loaded output = capture(:stderr) { Rails::Generators.find_by_namespace(:wrong) } - assert_match /\[WARNING\] Could not load generator/, output - assert_match /Rails 2\.x generator/, output + assert_match(/\[WARNING\] Could not load generator/, output) + assert_match(/Rails 2\.x generator/, output) end def test_invoke_with_nested_namespaces @@ -104,38 +104,38 @@ class GeneratorsTest < Rails::Generators::TestCase def test_rails_generators_help_with_builtin_information output = capture(:stdout){ Rails::Generators.help } - assert_match /Rails:/, output - assert_match /^ model$/, output - assert_match /^ scaffold_controller$/, output - assert_no_match /^ app$/, output + assert_match(/Rails:/, output) + assert_match(/^ model$/, output) + assert_match(/^ scaffold_controller$/, output) + assert_no_match(/^ app$/, output) end def test_rails_generators_help_does_not_include_app_nor_plugin_new output = capture(:stdout){ Rails::Generators.help } - assert_no_match /app/, output - assert_no_match /plugin_new/, output + assert_no_match(/app/, output) + assert_no_match(/plugin_new/, output) end def test_rails_generators_with_others_information output = capture(:stdout){ Rails::Generators.help } - assert_match /Fixjour:/, output - assert_match /^ fixjour$/, output + assert_match(/Fixjour:/, output) + assert_match(/^ fixjour$/, output) end def test_rails_generators_does_not_show_active_record_hooks output = capture(:stdout){ Rails::Generators.help } - assert_match /ActiveRecord:/, output - assert_match /^ active_record:fixjour$/, output + assert_match(/ActiveRecord:/, output) + assert_match(/^ active_record:fixjour$/, output) end def test_default_banner_should_show_generator_namespace klass = Rails::Generators.find_by_namespace(:foobar) - assert_match /^rails generate foobar:foobar/, klass.banner + assert_match(/^rails generate foobar:foobar/, klass.banner) end def test_default_banner_should_not_show_rails_generator_namespace klass = Rails::Generators.find_by_namespace(:model) - assert_match /^rails generate model/, klass.banner + assert_match(/^rails generate model/, klass.banner) end def test_no_color_sets_proper_shell |