Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1124 from amatsuda/fix_railties_warnings

Fix railties warnings
  • Loading branch information...
commit f7df1f8bf3d0c5307a75f3808e65851010b82450 2 parents 505defc + cce4615
@josevalim josevalim authored
View
6 railties/lib/rails/engine.rb
@@ -522,9 +522,9 @@ def load_seed
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|
View
2  railties/lib/rails/generators/actions.rb
@@ -278,7 +278,7 @@ def log(*args)
say args.first.to_s unless options.quiet?
else
args << (self.behavior == :invoke ? :green : :red)
- say_status *args
+ say_status(*args)
end
end
View
1  railties/lib/rails/generators/named_base.rb
@@ -13,6 +13,7 @@ class NamedBase < Base
: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
View
4 railties/test/generators/actions_test.rb
@@ -118,8 +118,8 @@ def test_environment_with_block_should_include_block_contents_in_environment_ini
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
View
26 railties/test/generators/app_generator_test.rb
@@ -155,7 +155,7 @@ def test_generator_if_skip_active_record_is_given
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 @@ def test_jquery_is_the_default_javascript_library
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 @@ def test_other_javascript_libraries
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 @@ def test_javascript_is_skipped_if_required
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 @@ def test_usage_read_from_file
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 @@ def test_new_hash_style
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 @@ def test_new_hash_style
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
View
4 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 @@ def test_controller_skeleton_is_created
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
View
6 railties/test/generators/helper_generator_test.rb
@@ -20,17 +20,17 @@ def test_invokes_default_test_framework
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
View
48 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 @@ def test_mailer_skeleton_is_created
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 @@ def test_invokes_default_template_engine_even_with_no_action
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 @@ def test_actions_are_turned_into_methods
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 @@ def test_actions_are_turned_into_methods
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
View
16 railties/test/generators/migration_generator_test.rb
@@ -35,8 +35,8 @@ def test_add_migration_with_attributes
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 @@ def test_remove_migration_with_attributes
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 @@ def test_should_create_empty_migrations_if_name_not_start_with_add_or_remove
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
View
33 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 @@ def test_migration_with_attributes
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 @@ def test_migration_timestamps_are_skipped
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 @@ def test_migration_is_skipped_on_skip_behavior
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 @@ def test_existing_migration_is_removed_on_force
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 @@ def test_fixture_is_skipped
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 @@ def test_index_is_added_for_belongs_to_association
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 @@ def test_index_is_added_for_references_association
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 @@ def test_index_is_skipped_for_belongs_to_association
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 @@ def test_index_is_skipped_for_references_association
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
View
28 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 @@ def test_mailer_skeleton_is_created
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
View
2  railties/test/generators/observer_generator_test.rb
@@ -22,6 +22,6 @@ def test_invokes_default_test_framework
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
View
6 railties/test/generators/plugin_generator_test.rb
@@ -32,7 +32,7 @@ def test_plugin_skeleton_is_created
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 @@ def test_invokes_default_test_framework
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 @@ def test_plugin_generator_on_revoke
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
View
14 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 @@ def test_resource_routes_are_added
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 @@ def test_plural_names_are_singularized
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 @@ def test_route_is_removed_on_revoke
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
View
46 railties/test/generators/scaffold_controller_generator_test.rb
@@ -14,39 +14,39 @@ def test_controller_skeleton_is_created
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 @@ def test_functional_tests
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 @@ def test_default_orm_is_used
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 @@ def self.all(klass)
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 @@ def test_new_hash_style
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 @@ def test_new_hash_style
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
View
4 railties/test/generators/session_migration_generator_test.rb
@@ -18,8 +18,8 @@ def test_session_migration_with_custom_table_name
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"
View
30 railties/test/generators_test.rb
@@ -28,7 +28,7 @@ def test_invoke_when_generator_is_not_found
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 @@ def test_find_by_namespace_without_base_or_context_looks_into_rails_namespace
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 @@ def test_invoke_with_nested_namespaces
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
Please sign in to comment.
Something went wrong with that request. Please try again.