aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/actions_test.rb36
-rw-r--r--railties/test/generators/app_generator_test.rb6
-rw-r--r--railties/test/generators/model_generator_test.rb6
-rw-r--r--railties/test/generators/namespaced_generators_test.rb6
-rw-r--r--railties/test/generators/orm_test.rb4
-rw-r--r--railties/test/generators/plugin_new_generator_test.rb2
-rw-r--r--railties/test/generators/resource_generator_test.rb2
-rw-r--r--railties/test/generators/scaffold_generator_test.rb2
-rw-r--r--railties/test/generators/shared_generator_tests.rb14
9 files changed, 39 insertions, 39 deletions
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index bc086c5986..8af92479c3 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -99,7 +99,7 @@ class ActionsTest < Rails::Generators::TestCase
def test_environment_should_include_data_in_environment_initializer_block_with_env_option
run_generator
autoload_paths = 'config.autoload_paths += %w["#{Rails.root}/app/extras"]'
- action :environment, autoload_paths, :env => 'development'
+ action :environment, autoload_paths, env: 'development'
assert_file "config/environments/development.rb", /Application\.configure do\n #{Regexp.escape(autoload_paths)}/
end
@@ -124,7 +124,7 @@ class ActionsTest < Rails::Generators::TestCase
def test_git_with_hash_should_run_each_command_using_git_scm
generator.expects(:run).times(2)
- action :git, :rm => 'README', :add => '.'
+ action :git, rm: 'README', add: '.'
end
def test_vendor_should_write_data_to_file_in_vendor
@@ -138,8 +138,8 @@ class ActionsTest < Rails::Generators::TestCase
end
def test_rakefile_should_write_date_to_file_in_lib_tasks
- action :rakefile, 'myapp.rake', 'task :run => [:environment]'
- assert_file 'lib/tasks/myapp.rake', 'task :run => [:environment]'
+ action :rakefile, 'myapp.rake', 'task run: [:environment]'
+ assert_file 'lib/tasks/myapp.rake', 'task run: [:environment]'
end
def test_initializer_should_write_date_to_file_in_config_initializers
@@ -148,12 +148,12 @@ class ActionsTest < Rails::Generators::TestCase
end
def test_generate_should_run_script_generate_with_argument_and_options
- generator.expects(:run_ruby_script).once.with('script/rails generate model MyModel', :verbose => false)
+ generator.expects(:run_ruby_script).once.with('script/rails generate model MyModel', verbose: false)
action :generate, 'model', 'MyModel'
end
def test_rake_should_run_rake_command_with_default_env
- generator.expects(:run).once.with("rake log:clear RAILS_ENV=development", :verbose => false)
+ generator.expects(:run).once.with("rake log:clear RAILS_ENV=development", verbose: false)
old_env, ENV['RAILS_ENV'] = ENV["RAILS_ENV"], nil
action :rake, 'log:clear'
ensure
@@ -161,12 +161,12 @@ class ActionsTest < Rails::Generators::TestCase
end
def test_rake_with_env_option_should_run_rake_command_in_env
- generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', :verbose => false)
- action :rake, 'log:clear', :env => 'production'
+ generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', verbose: false)
+ action :rake, 'log:clear', env: 'production'
end
def test_rake_with_rails_env_variable_should_run_rake_command_in_env
- generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', :verbose => false)
+ generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', verbose: false)
old_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "production"
action :rake, 'log:clear'
ensure
@@ -174,29 +174,29 @@ class ActionsTest < Rails::Generators::TestCase
end
def test_env_option_should_win_over_rails_env_variable_when_running_rake
- generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', :verbose => false)
+ generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', verbose: false)
old_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "staging"
- action :rake, 'log:clear', :env => 'production'
+ action :rake, 'log:clear', env: 'production'
ensure
ENV["RAILS_ENV"] = old_env
end
def test_rake_with_sudo_option_should_run_rake_command_with_sudo
- generator.expects(:run).once.with("sudo rake log:clear RAILS_ENV=development", :verbose => false)
+ generator.expects(:run).once.with("sudo rake log:clear RAILS_ENV=development", verbose: false)
old_env, ENV['RAILS_ENV'] = ENV["RAILS_ENV"], nil
- action :rake, 'log:clear', :sudo => true
+ action :rake, 'log:clear', sudo: true
ensure
ENV["RAILS_ENV"] = old_env
end
def test_capify_should_run_the_capify_command
- generator.expects(:run).once.with('capify .', :verbose => false)
+ generator.expects(:run).once.with('capify .', verbose: false)
action :capify!
end
def test_route_should_add_data_to_the_routes_block_in_config_routes
run_generator
- route_command = "route '/login', :controller => 'sessions', :action => 'new'"
+ route_command = "route '/login', controller: 'sessions', action: 'new'"
action :route, route_command
assert_file 'config/routes.rb', /#{Regexp.escape(route_command)}/
end
@@ -208,7 +208,7 @@ class ActionsTest < Rails::Generators::TestCase
end
def test_readme_with_quiet
- generator(default_arguments, :quiet => true)
+ generator(default_arguments, quiet: true)
run_generator
Rails::Generators::AppGenerator.expects(:source_root).times(2).returns(destination_root)
assert_no_match(/Welcome to Rails/, action(:readme, "README.rdoc"))
@@ -223,12 +223,12 @@ class ActionsTest < Rails::Generators::TestCase
end
def test_log_with_quiet
- generator(default_arguments, :quiet => true)
+ generator(default_arguments, quiet: true)
assert_equal("", action(:log, "YES"))
end
def test_log_with_status_with_quiet
- generator(default_arguments, :quiet => true)
+ generator(default_arguments, quiet: true)
assert_equal("", action(:log, :yes, "YES"))
end
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 6b6a6b6099..e5397bf4f3 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -107,8 +107,8 @@ class AppGeneratorTest < Rails::Generators::TestCase
FileUtils.mv(app_root, app_moved_root)
- generator = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true },
- :destination_root => app_moved_root, :shell => @shell
+ generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true },
+ destination_root: app_moved_root, shell: @shell
generator.send(:app_const)
quietly { generator.send(:create_config_files) }
assert_file "myapp_moved/config/environment.rb", /Myapp::Application\.initialize!/
@@ -123,7 +123,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
Rails.application.class.stubs(:name).returns("Myapp")
Rails.application.stubs(:is_a?).returns(Rails::Application)
- generator = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true }, :destination_root => app_root, :shell => @shell
+ generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell
generator.send(:app_const)
quietly { generator.send(:create_config_files) }
assert_file "myapp/config/initializers/session_store.rb", /_myapp_session/
diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb
index a90ad5cde0..0c7ff0ebe7 100644
--- a/railties/test/generators/model_generator_test.rb
+++ b/railties/test/generators/model_generator_test.rb
@@ -242,19 +242,19 @@ class ModelGeneratorTest < Rails::Generators::TestCase
def test_migration_is_skipped_on_skip_behavior
run_generator
- output = run_generator ["Account"], :behavior => :skip
+ output = run_generator ["Account"], behavior: :skip
assert_match %r{skip\s+db/migrate/\d+_create_accounts.rb}, output
end
def test_migration_error_is_not_shown_on_revoke
run_generator
- error = capture(:stderr){ run_generator ["Account"], :behavior => :revoke }
+ error = capture(:stderr){ run_generator ["Account"], behavior: :revoke }
assert_no_match(/Another migration is already named create_accounts/, error)
end
def test_migration_is_removed_on_revoke
run_generator
- run_generator ["Account"], :behavior => :revoke
+ run_generator ["Account"], behavior: :revoke
assert_no_migration "db/migrate/create_accounts.rb"
end
diff --git a/railties/test/generators/namespaced_generators_test.rb b/railties/test/generators/namespaced_generators_test.rb
index d48712e51f..4b168ae110 100644
--- a/railties/test/generators/namespaced_generators_test.rb
+++ b/railties/test/generators/namespaced_generators_test.rb
@@ -263,7 +263,7 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase
def test_scaffold_on_revoke
run_generator
- run_generator ["product_line"], :behavior => :revoke
+ run_generator ["product_line"], behavior: :revoke
# Model
assert_no_file "app/models/test_app/product_line.rb"
@@ -335,7 +335,7 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase
def test_scaffold_with_namespace_on_revoke
run_generator [ "admin/role", "name:string", "description:string" ]
- run_generator [ "admin/role" ], :behavior => :revoke
+ run_generator [ "admin/role" ], behavior: :revoke
# Model
assert_file "app/models/test_app/admin.rb" # ( should not be remove )
@@ -408,7 +408,7 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase
def test_scaffold_with_nested_namespace_on_revoke
run_generator [ "admin/user/special/role", "name:string", "description:string" ]
- run_generator [ "admin/user/special/role" ], :behavior => :revoke
+ run_generator [ "admin/user/special/role" ], behavior: :revoke
# Model
assert_file "app/models/test_app/admin/user/special.rb" # ( should not be remove )
diff --git a/railties/test/generators/orm_test.rb b/railties/test/generators/orm_test.rb
index 9dd3d3e0ec..88ae930554 100644
--- a/railties/test/generators/orm_test.rb
+++ b/railties/test/generators/orm_test.rb
@@ -20,12 +20,12 @@ class OrmTest < Rails::Generators::TestCase
tests Rails::Generators::ScaffoldControllerGenerator
def test_orm_class_returns_custom_generator_if_supported_custom_orm_set
- g = generator ["Foo"], :orm => "ORMWithGenerators"
+ g = generator ["Foo"], orm: "ORMWithGenerators"
assert_equal ORMWithGenerators::Generators::ActiveModel, g.send(:orm_class)
end
def test_orm_class_returns_rails_generator_if_unsupported_custom_orm_set
- g = generator ["Foo"], :orm => "ORMWithoutGenerators"
+ g = generator ["Foo"], orm: "ORMWithoutGenerators"
assert_equal Rails::Generators::ActiveModel, g.send(:orm_class)
end
diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb
index dddbfa64b6..6974db5751 100644
--- a/railties/test/generators/plugin_new_generator_test.rb
+++ b/railties/test/generators/plugin_new_generator_test.rb
@@ -379,7 +379,7 @@ class CustomPluginGeneratorTest < Rails::Generators::TestCase
run_generator([destination_root, "-b", "#{Rails.root}/lib/plugin_builders/spec_builder.rb"])
assert_file 'spec/spec_helper.rb'
assert_file 'spec/dummy'
- assert_file 'Rakefile', /task :default => :spec/
+ assert_file 'Rakefile', /task default: :spec/
assert_file 'Rakefile', /# spec tasks in rakefile/
end
diff --git a/railties/test/generators/resource_generator_test.rb b/railties/test/generators/resource_generator_test.rb
index 0ae0841442..3d4e694361 100644
--- a/railties/test/generators/resource_generator_test.rb
+++ b/railties/test/generators/resource_generator_test.rb
@@ -80,7 +80,7 @@ class ResourceGeneratorTest < Rails::Generators::TestCase
def test_route_is_removed_on_revoke
run_generator
- run_generator ["account"], :behavior => :revoke
+ run_generator ["account"], behavior: :revoke
assert_file "config/routes.rb" do |route|
assert_no_match(/resources :accounts$/, route)
diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb
index dc825c7c99..efe47cdfcb 100644
--- a/railties/test/generators/scaffold_generator_test.rb
+++ b/railties/test/generators/scaffold_generator_test.rb
@@ -99,7 +99,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
def test_scaffold_on_revoke
run_generator
- run_generator ["product_line"], :behavior => :revoke
+ run_generator ["product_line"], behavior: :revoke
# Model
assert_no_file "app/models/product_line.rb"
diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb
index a4bdfcf438..1e5a4545a1 100644
--- a/railties/test/generators/shared_generator_tests.rb
+++ b/railties/test/generators/shared_generator_tests.rb
@@ -87,7 +87,7 @@ module SharedGeneratorTests
template = %{ say "It works!" }
template.instance_eval "def read; self; end" # Make the string respond to read
- generator([destination_root], :template => path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template)
+ generator([destination_root], template: path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template)
assert_match(/It works!/, capture(:stdout) { generator.invoke_all })
end
@@ -96,31 +96,31 @@ module SharedGeneratorTests
template = %{ say "It works!" }
template.instance_eval "def read; self; end" # Make the string respond to read
- generator([destination_root], :template => path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template)
+ generator([destination_root], template: path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template)
assert_match(/It works!/, capture(:stdout) { generator.invoke_all })
end
def test_dev_option
- generator([destination_root], :dev => true).expects(:bundle_command).with('install').once
+ generator([destination_root], dev: true).expects(:bundle_command).with('install').once
quietly { generator.invoke_all }
rails_path = File.expand_path('../../..', Rails.root)
assert_file 'Gemfile', /^gem\s+["']rails["'],\s+path:\s+["']#{Regexp.escape(rails_path)}["']$/
end
def test_edge_option
- generator([destination_root], :edge => true).expects(:bundle_command).with('install').once
+ generator([destination_root], edge: true).expects(:bundle_command).with('install').once
quietly { generator.invoke_all }
assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["']$}
end
def test_skip_gemfile
- generator([destination_root], :skip_gemfile => true).expects(:bundle_command).never
+ generator([destination_root], skip_gemfile: true).expects(:bundle_command).never
quietly { generator.invoke_all }
assert_no_file 'Gemfile'
end
def test_skip_bundle
- generator([destination_root], :skip_bundle => true).expects(:bundle_command).never
+ generator([destination_root], skip_bundle: true).expects(:bundle_command).never
quietly { generator.invoke_all }
# skip_bundle is only about running bundle install, ensure the Gemfile is still
@@ -192,7 +192,7 @@ module SharedCustomGeneratorTests
template = "class #{builder_class}; end"
template.instance_eval "def read; self; end" # Make the string respond to read
- generator([destination_root], :builder => url).expects(:open).with(url, 'Accept' => 'application/x-thor-template').returns(template)
+ generator([destination_root], builder: url).expects(:open).with(url, 'Accept' => 'application/x-thor-template').returns(template)
quietly { generator.invoke_all }
default_files.each{ |path| assert_no_file(path) }