diff options
author | Robin Dupret <robin.dupret@gmail.com> | 2012-10-14 12:03:39 +0200 |
---|---|---|
committer | Robin Dupret <robin.dupret@gmail.com> | 2012-10-14 18:26:58 +0200 |
commit | 5ad7f8ab418f0c760dbb584f7c78d94ce32e9ee3 (patch) | |
tree | 9e58227af8a363398a03b8010156d5a84d59dea9 /railties/test | |
parent | ca618d473dcb9b5cc4000d057df9322376900622 (diff) | |
download | rails-5ad7f8ab418f0c760dbb584f7c78d94ce32e9ee3.tar.gz rails-5ad7f8ab418f0c760dbb584f7c78d94ce32e9ee3.tar.bz2 rails-5ad7f8ab418f0c760dbb584f7c78d94ce32e9ee3.zip |
Use Ruby 1.9 Hash syntax in railties
Diffstat (limited to 'railties/test')
32 files changed, 215 insertions, 215 deletions
diff --git a/railties/test/application/asset_debugging_test.rb b/railties/test/application/asset_debugging_test.rb index a7b3ae1e9a..1eddfac664 100644 --- a/railties/test/application/asset_debugging_test.rb +++ b/railties/test/application/asset_debugging_test.rb @@ -7,7 +7,7 @@ module ApplicationTests include Rack::Test::Methods def setup - build_app(:initializers => true) + build_app(initializers: true) app_file "app/assets/javascripts/application.js", "//= require_tree ." app_file "app/assets/javascripts/xmlhr.js", "function f1() { alert(); }" @@ -15,7 +15,7 @@ module ApplicationTests app_file "config/routes.rb", <<-RUBY AppTemplate::Application.routes.draw do - get '/posts', :to => "posts#index" + get '/posts', to: "posts#index" end RUBY diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index 8a76b2f614..2506d19e6d 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -8,7 +8,7 @@ module ApplicationTests include Rack::Test::Methods def setup - build_app(:initializers => true) + build_app(initializers: true) boot_rails end @@ -44,7 +44,7 @@ module ApplicationTests app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get '*path', :to => lambda { |env| [200, { "Content-Type" => "text/html" }, "Not an asset"] } + get '*path', to: lambda { |env| [200, { "Content-Type" => "text/html" }, "Not an asset"] } end RUBY @@ -353,7 +353,7 @@ module ApplicationTests class ::OmgController < ActionController::Base def index flash[:cool_story] = true - render :text => "ok" + render text: "ok" end end diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 3691c5e3d5..7a120410ba 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -239,7 +239,7 @@ module ApplicationTests class ::OmgController < ActionController::Base def index cookies.signed[:some_key] = "some_value" - render :text => env["action_dispatch.secret_token"] + render text: env["action_dispatch.secret_token"] end end @@ -252,7 +252,7 @@ module ApplicationTests class ::OmgController < ActionController::Base def index - render :inline => "<%= csrf_meta_tags %>" + render inline: "<%= csrf_meta_tags %>" end end @@ -272,11 +272,11 @@ module ApplicationTests app_file 'app/controllers/posts_controller.rb', <<-RUBY class PostsController < ApplicationController def show - render :inline => "<%= begin; form_for(Post.new) {}; rescue => e; e.to_s; end %>" + render inline: "<%= begin; form_for(Post.new) {}; rescue => e; e.to_s; end %>" end def update - render :text => "update" + render text: "update" end end RUBY @@ -291,7 +291,7 @@ module ApplicationTests token = "cf50faa3fe97702ca1ae" PostsController.any_instance.stubs(:form_authenticity_token).returns(token) - params = {:authenticity_token => token} + params = {authenticity_token: token} get "/posts/1" assert_match(/patch/, last_response.body) @@ -316,7 +316,7 @@ module ApplicationTests class ::OmgController < ActionController::Base def index - render :inline => "<%= csrf_meta_tags %>" + render inline: "<%= csrf_meta_tags %>" end end @@ -440,7 +440,7 @@ module ApplicationTests class ::OmgController < ActionController::Base def index - render :inline => "<%= image_path('foo.jpg') %>" + render inline: "<%= image_path('foo.jpg') %>" end end @@ -493,7 +493,7 @@ module ApplicationTests class ::OmgController < ActionController::Base def index - render :text => env["action_dispatch.show_exceptions"] + render text: env["action_dispatch.show_exceptions"] end end @@ -503,7 +503,7 @@ module ApplicationTests test "config.action_controller.wrap_parameters is set in ActionController::Base" do app_file 'config/initializers/wrap_parameters.rb', <<-RUBY - ActionController::Base.wrap_parameters :format => [:json] + ActionController::Base.wrap_parameters format: [:json] RUBY app_file 'app/models/post.rb', <<-RUBY @@ -523,7 +523,7 @@ module ApplicationTests app_file 'app/controllers/posts_controller.rb', <<-RUBY class PostsController < ApplicationController def create - render :text => params[:post].inspect + render text: params[:post].inspect end end RUBY @@ -544,7 +544,7 @@ module ApplicationTests app_file 'app/controllers/posts_controller.rb', <<-RUBY class PostsController < ActionController::Base def create - render :text => params[:post].permitted? ? "permitted" : "forbidden" + render text: params[:post].permitted? ? "permitted" : "forbidden" end end RUBY @@ -558,7 +558,7 @@ module ApplicationTests require "#{app_path}/config/environment" - post "/posts", {:post => {"title" =>"zomg"}} + post "/posts", {post: {"title" =>"zomg"}} assert_equal 'permitted', last_response.body end @@ -570,8 +570,8 @@ module ApplicationTests class ::OmgController < ActionController::Base def index respond_to do |format| - format.html { render :text => "HTML" } - format.xml { render :text => "XML" } + format.html { render text: "HTML" } + format.xml { render text: "XML" } end end end @@ -579,7 +579,7 @@ module ApplicationTests get "/", {}, "HTTP_ACCEPT" => "application/xml" assert_equal 'HTML', last_response.body - get "/", { :format => :xml }, "HTTP_ACCEPT" => "application/xml" + get "/", { format: :xml }, "HTTP_ACCEPT" => "application/xml" assert_equal 'XML', last_response.body end diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index b80244f1d2..bc0af499c1 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -48,22 +48,22 @@ module ApplicationTests c.generators.orm = :data_mapper c.generators.test_framework = :rspec c.generators.helper = false - expected = { :rails => { :orm => :data_mapper, :test_framework => :rspec, :helper => false } } + expected = { rails: { orm: :data_mapper, test_framework: :rspec, helper: false } } assert_equal(expected, c.generators.options) end end test "generators set rails aliases" do with_config do |c| - c.generators.aliases = { :rails => { :test_framework => "-w" } } - expected = { :rails => { :test_framework => "-w" } } + c.generators.aliases = { rails: { test_framework: "-w" } } + expected = { rails: { test_framework: "-w" } } assert_equal expected, c.generators.aliases end end test "generators aliases, options, templates and fallbacks on initialization" do add_to_config <<-RUBY - config.generators.rails :aliases => { :test_framework => "-w" } + config.generators.rails aliases: { test_framework: "-w" } config.generators.orm :data_mapper config.generators.test_framework :rspec config.generators.fallbacks[:shoulda] = :test_unit @@ -76,7 +76,7 @@ module ApplicationTests assert_equal :rspec, Rails::Generators.options[:rails][:test_framework] assert_equal "-w", Rails::Generators.aliases[:rails][:test_framework] - assert_equal Hash[:shoulda => :test_unit], Rails::Generators.fallbacks + assert_equal Hash[shoulda: :test_unit], Rails::Generators.fallbacks assert_equal ["some/where"], Rails::Generators.templates_path end @@ -95,31 +95,31 @@ module ApplicationTests test "generators with hashes for options and aliases" do with_bare_config do |c| c.generators do |g| - g.orm :data_mapper, :migration => false - g.plugin :aliases => { :generator => "-g" }, - :generator => true + g.orm :data_mapper, migration: false + g.plugin aliases: { generator: "-g" }, + generator: true end expected = { - :rails => { :orm => :data_mapper }, - :plugin => { :generator => true }, - :data_mapper => { :migration => false } + rails: { orm: :data_mapper }, + plugin: { generator: true }, + data_mapper: { migration: false } } assert_equal expected, c.generators.options - assert_equal({ :plugin => { :generator => "-g" } }, c.generators.aliases) + assert_equal({ plugin: { generator: "-g" } }, c.generators.aliases) end end test "generators with string and hash for options should generate symbol keys" do with_bare_config do |c| c.generators do |g| - g.orm 'data_mapper', :migration => false + g.orm 'data_mapper', migration: false end expected = { - :rails => { :orm => :data_mapper }, - :data_mapper => { :migration => false } + rails: { orm: :data_mapper }, + data_mapper: { migration: false } } assert_equal expected, c.generators.options diff --git a/railties/test/application/initializers/i18n_test.rb b/railties/test/application/initializers/i18n_test.rb index 02d20bc150..489b7ddb92 100644 --- a/railties/test/application/initializers/i18n_test.rb +++ b/railties/test/application/initializers/i18n_test.rb @@ -143,7 +143,7 @@ en: I18n::Railtie.config.i18n.fallbacks = true load_app assert I18n.backend.class.included_modules.include?(I18n::Backend::Fallbacks) - assert_fallbacks :de => [:de, :en] + assert_fallbacks de: [:de, :en] end test "config.i18n.fallbacks = true initializes I18n.fallbacks with default settings even when backend changes" do @@ -151,37 +151,37 @@ en: I18n::Railtie.config.i18n.backend = Class.new(I18n::Backend::Simple).new load_app assert I18n.backend.class.included_modules.include?(I18n::Backend::Fallbacks) - assert_fallbacks :de => [:de, :en] + assert_fallbacks de: [:de, :en] end test "config.i18n.fallbacks.defaults = [:'en-US'] initializes fallbacks with en-US as a fallback default" do I18n::Railtie.config.i18n.fallbacks.defaults = [:'en-US'] load_app - assert_fallbacks :de => [:de, :'en-US', :en] + assert_fallbacks de: [:de, :'en-US', :en] end test "config.i18n.fallbacks.map = { :ca => :'es-ES' } initializes fallbacks with a mapping ca => es-ES" do I18n::Railtie.config.i18n.fallbacks.map = { :ca => :'es-ES' } load_app - assert_fallbacks :ca => [:ca, :"es-ES", :es, :en] + assert_fallbacks ca: [:ca, :"es-ES", :es, :en] end test "[shortcut] config.i18n.fallbacks = [:'en-US'] initializes fallbacks with en-US as a fallback default" do I18n::Railtie.config.i18n.fallbacks = [:'en-US'] load_app - assert_fallbacks :de => [:de, :'en-US', :en] + assert_fallbacks de: [:de, :'en-US', :en] end test "[shortcut] config.i18n.fallbacks = [{ :ca => :'es-ES' }] initializes fallbacks with a mapping de-AT => de-DE" do I18n::Railtie.config.i18n.fallbacks.map = { :ca => :'es-ES' } load_app - assert_fallbacks :ca => [:ca, :"es-ES", :es, :en] + assert_fallbacks ca: [:ca, :"es-ES", :es, :en] end test "[shortcut] config.i18n.fallbacks = [:'en-US', { :ca => :'es-ES' }] initializes fallbacks with the given arguments" do I18n::Railtie.config.i18n.fallbacks = [:'en-US', { :ca => :'es-ES' }] load_app - assert_fallbacks :ca => [:ca, :"es-ES", :es, :'en-US', :en] + assert_fallbacks ca: [:ca, :"es-ES", :es, :'en-US', :en] end end end diff --git a/railties/test/application/initializers/notifications_test.rb b/railties/test/application/initializers/notifications_test.rb index d866a63fe0..baae6fd928 100644 --- a/railties/test/application/initializers/notifications_test.rb +++ b/railties/test/application/initializers/notifications_test.rb @@ -33,7 +33,7 @@ module ApplicationTests ActiveRecord::Base.logger = logger # Mimic Active Record notifications - instrument "sql.active_record", :name => "SQL", :sql => "SHOW tables" + instrument "sql.active_record", name: "SQL", sql: "SHOW tables" wait assert_equal 1, logger.logged(:debug).size diff --git a/railties/test/application/loading_test.rb b/railties/test/application/loading_test.rb index fcbc3c048c..ad7172c514 100644 --- a/railties/test/application/loading_test.rb +++ b/railties/test/application/loading_test.rb @@ -19,14 +19,14 @@ class LoadingTest < ActiveSupport::TestCase test "constants in app are autoloaded" do app_file "app/models/post.rb", <<-MODEL class Post < ActiveRecord::Base - validates_acceptance_of :title, :accept => "omg" + validates_acceptance_of :title, accept: "omg" end MODEL require "#{rails_root}/config/environment" setup_ar! - p = Post.create(:title => 'omg') + p = Post.create(title: 'omg') assert_equal 1, Post.count assert_equal 'omg', p.title p = Post.first @@ -36,7 +36,7 @@ class LoadingTest < ActiveSupport::TestCase test "models without table do not panic on scope definitions when loaded" do app_file "app/models/user.rb", <<-MODEL class User < ActiveRecord::Base - default_scope where(:published => true) + default_scope where(published: true) end MODEL @@ -76,8 +76,8 @@ class LoadingTest < ActiveSupport::TestCase app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get '/load', :to => lambda { |env| [200, {}, Post.all] } - get '/unload', :to => lambda { |env| [200, {}, []] } + get '/load', to: lambda { |env| [200, {}, Post.all] } + get '/unload', to: lambda { |env| [200, {}, []] } end RUBY @@ -106,7 +106,7 @@ class LoadingTest < ActiveSupport::TestCase app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get '/c', :to => lambda { |env| [200, {"Content-Type" => "text/plain"}, [User.counter.to_s]] } + get '/c', to: lambda { |env| [200, {"Content-Type" => "text/plain"}, [User.counter.to_s]] } end RUBY @@ -145,7 +145,7 @@ class LoadingTest < ActiveSupport::TestCase app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get '/c', :to => lambda { |env| [200, {"Content-Type" => "text/plain"}, [User.counter.to_s]] } + get '/c', to: lambda { |env| [200, {"Content-Type" => "text/plain"}, [User.counter.to_s]] } end RUBY @@ -181,7 +181,7 @@ class LoadingTest < ActiveSupport::TestCase app_file 'config/routes.rb', <<-RUBY $counter = 0 AppTemplate::Application.routes.draw do - get '/c', :to => lambda { |env| User; [200, {"Content-Type" => "text/plain"}, [$counter.to_s]] } + get '/c', to: lambda { |env| User; [200, {"Content-Type" => "text/plain"}, [$counter.to_s]] } end RUBY @@ -212,8 +212,8 @@ class LoadingTest < ActiveSupport::TestCase app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get '/title', :to => lambda { |env| [200, {"Content-Type" => "text/plain"}, [Post.new.title]] } - get '/body', :to => lambda { |env| [200, {"Content-Type" => "text/plain"}, [Post.new.body]] } + get '/title', to: lambda { |env| [200, {"Content-Type" => "text/plain"}, [Post.new.title]] } + get '/body', to: lambda { |env| [200, {"Content-Type" => "text/plain"}, [Post.new.body]] } end RUBY @@ -229,7 +229,7 @@ class LoadingTest < ActiveSupport::TestCase class CreatePosts < ActiveRecord::Migration def change create_table :posts do |t| - t.string :title, :default => "TITLE" + t.string :title, default: "TITLE" end end end @@ -244,7 +244,7 @@ class LoadingTest < ActiveSupport::TestCase app_file "db/migrate/2_add_body_to_posts.rb", <<-MIGRATION class AddBodyToPosts < ActiveRecord::Migration def change - add_column :posts, :body, :text, :default => "BODY" + add_column :posts, :body, :text, default: "BODY" end end MIGRATION @@ -297,9 +297,9 @@ class LoadingTest < ActiveSupport::TestCase protected def setup_ar! - ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:") + ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") ActiveRecord::Migration.verbose = false - ActiveRecord::Schema.define(:version => 1) do + ActiveRecord::Schema.define(version: 1) do create_table :posts do |t| t.string :title end diff --git a/railties/test/application/middleware/cache_test.rb b/railties/test/application/middleware/cache_test.rb index fffe79f9cc..9b6c76e7aa 100644 --- a/railties/test/application/middleware/cache_test.rb +++ b/railties/test/application/middleware/cache_test.rb @@ -19,17 +19,17 @@ module ApplicationTests controller :expires, <<-RUBY class ExpiresController < ApplicationController def expires_header - expires_in 10, :public => !params[:private] - render :text => SecureRandom.hex(16) + expires_in 10, public: !params[:private] + render text: SecureRandom.hex(16) end def expires_etag - render_conditionally(:etag => "1") + render_conditionally(etag: "1") end def expires_last_modified $last_modified ||= Time.now.utc - render_conditionally(:last_modified => $last_modified) + render_conditionally(last_modified: $last_modified) end def keeps_if_modified_since @@ -37,8 +37,8 @@ module ApplicationTests end private def render_conditionally(headers) - if stale?(headers.merge(:public => !params[:private])) - render :text => SecureRandom.hex(16) + if stale?(headers.merge(public: !params[:private])) + render text: SecureRandom.hex(16) end end end @@ -96,13 +96,13 @@ module ApplicationTests def test_cache_works_with_expires_private simple_controller - get "/expires/expires_header", :private => true + get "/expires/expires_header", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_equal "private, max-age=10", last_response.headers["Cache-Control"] body = last_response.body - get "/expires/expires_header", :private => true + get "/expires/expires_header", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_not_equal body, last_response.body end @@ -125,14 +125,14 @@ module ApplicationTests def test_cache_works_with_etags_private simple_controller - get "/expires/expires_etag", :private => true + get "/expires/expires_etag", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_equal "must-revalidate, private, max-age=0", last_response.headers["Cache-Control"] body = last_response.body etag = last_response.headers["ETag"] - get "/expires/expires_etag", {:private => true}, "If-None-Match" => etag + get "/expires/expires_etag", {private: true}, "If-None-Match" => etag assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_not_equal body, last_response.body end @@ -155,14 +155,14 @@ module ApplicationTests def test_cache_works_with_last_modified_private simple_controller - get "/expires/expires_last_modified", :private => true + get "/expires/expires_last_modified", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_equal "must-revalidate, private, max-age=0", last_response.headers["Cache-Control"] body = last_response.body last = last_response.headers["Last-Modified"] - get "/expires/expires_last_modified", {:private => true}, "If-Modified-Since" => last + get "/expires/expires_last_modified", {private: true}, "If-Modified-Since" => last assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_not_equal body, last_response.body end diff --git a/railties/test/application/middleware/session_test.rb b/railties/test/application/middleware/session_test.rb index 06dec81d40..5ce41caf61 100644 --- a/railties/test/application/middleware/session_test.rb +++ b/railties/test/application/middleware/session_test.rb @@ -36,7 +36,7 @@ module ApplicationTests flash[:notice] = "notice" end - render :nothing => true + render nothing: true end end diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index b2443e6503..c03d35e926 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -81,10 +81,10 @@ module ApplicationTests test "ActionDispatch::SSL is configured with options when given" do add_to_config "config.force_ssl = true" - add_to_config "config.ssl_options = { :host => 'example.com' }" + add_to_config "config.ssl_options = { host: 'example.com' }" boot! - assert_equal AppTemplate::Application.middleware.first.args, [{:host => 'example.com'}] + assert_equal AppTemplate::Application.middleware.first.args, [{host: 'example.com'}] end test "removing Active Record omits its middleware" do @@ -169,9 +169,9 @@ module ApplicationTests class ::OmgController < ActionController::Base def index if params[:nothing] - render :text => "" + render text: "" else - render :text => "OMG" + render text: "OMG" end end end diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 2e7426150c..c5a68a5152 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -46,7 +46,7 @@ module ApplicationTests end rake_tasks do - task :do_nothing => :environment do + task do_nothing: :environment do end end RUBY @@ -60,7 +60,7 @@ module ApplicationTests config.eager_load = true rake_tasks do - task :do_nothing => :environment do + task do_nothing: :environment do Hello.new.world end end @@ -109,7 +109,7 @@ module ApplicationTests def test_rake_routes_calls_the_route_inspector app_file "config/routes.rb", <<-RUBY AppTemplate::Application.routes.draw do - get '/cart', :to => 'cart#show' + get '/cart', to: 'cart#show' end RUBY assert_equal "cart GET /cart(.:format) cart#show\n", Dir.chdir(app_path){ `rake routes` } @@ -118,7 +118,7 @@ module ApplicationTests def test_logger_is_flushed_when_exiting_production_rake_tasks add_to_config <<-RUBY rake_tasks do - task :log_something => :environment do + task log_something: :environment do Rails.logger.error("Sample log message") end end @@ -233,7 +233,7 @@ module ApplicationTests app_file "lib/tasks/count_user.rake", <<-RUBY namespace :user do - task :count => :environment do + task count: :environment do puts User.count end end diff --git a/railties/test/application/routing_test.rb b/railties/test/application/routing_test.rb index 396b1849d8..ffcdeac7f0 100644 --- a/railties/test/application/routing_test.rb +++ b/railties/test/application/routing_test.rb @@ -50,7 +50,7 @@ module ApplicationTests controller :foo, <<-RUBY class FooController < ApplicationController def index - render :inline => "<%= foo_or_bar? %>" + render inline: "<%= foo_or_bar? %>" end end RUBY @@ -76,7 +76,7 @@ module ApplicationTests test "mount rack app" do app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - mount lambda { |env| [200, {}, [env["PATH_INFO"]]] }, :at => "/blog" + mount lambda { |env| [200, {}, [env["PATH_INFO"]]] }, at: "/blog" # The line below is required because mount sometimes # fails when a resource route is added. resource :user @@ -91,7 +91,7 @@ module ApplicationTests controller :foo, <<-RUBY class FooController < ApplicationController def index - render :text => "foo" + render text: "foo" end end RUBY @@ -99,7 +99,7 @@ module ApplicationTests controller :bar, <<-RUBY class BarController < ActionController::Base def index - render :text => "bar" + render text: "bar" end end RUBY @@ -121,7 +121,7 @@ module ApplicationTests controller 'foo', <<-RUBY class FooController < ApplicationController def index - render :text => "foo" + render text: "foo" end end RUBY @@ -130,7 +130,7 @@ module ApplicationTests module Admin class FooController < ApplicationController def index - render :text => "admin::foo" + render text: "admin::foo" end end end @@ -138,8 +138,8 @@ module ApplicationTests app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get 'admin/foo', :to => 'admin/foo#index' - get 'foo', :to => 'foo#index' + get 'admin/foo', to: 'admin/foo#index' + get 'foo', to: 'foo#index' end RUBY @@ -183,18 +183,18 @@ module ApplicationTests controller :foo, <<-RUBY class FooController < ApplicationController def bar - render :text => "bar" + render text: "bar" end def baz - render :text => "baz" + render text: "baz" end end RUBY app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get 'foo', :to => 'foo#bar' + get 'foo', to: 'foo#bar' end RUBY @@ -205,7 +205,7 @@ module ApplicationTests app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get 'foo', :to => 'foo#baz' + get 'foo', to: 'foo#baz' end RUBY @@ -226,7 +226,7 @@ module ApplicationTests app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get 'foo', :to => ::InitializeRackApp + get 'foo', to: ::InitializeRackApp end RUBY @@ -257,7 +257,7 @@ module ApplicationTests controller 'yazilar', <<-RUBY class YazilarController < ApplicationController def index - render :text => 'yazilar#index' + render text: 'yazilar#index' end end RUBY diff --git a/railties/test/application/url_generation_test.rb b/railties/test/application/url_generation_test.rb index f7e60749a7..4ecb94b65e 100644 --- a/railties/test/application/url_generation_test.rb +++ b/railties/test/application/url_generation_test.rb @@ -15,7 +15,7 @@ module ApplicationTests class MyApp < Rails::Application config.secret_token = "3b7cd727ee24e8444053437c36cc66c4" - config.session_store :cookie_store, :key => "_myapp_session" + config.session_store :cookie_store, key: "_myapp_session" config.active_support.deprecation = :log end @@ -26,12 +26,12 @@ module ApplicationTests class ::OmgController < ::ApplicationController def index - render :text => omg_path + render text: omg_path end end MyApp.routes.draw do - get "/" => "omg#index", :as => :omg + get "/" => "omg#index", as: :omg end require 'rack/test' diff --git a/railties/test/commands/console_test.rb b/railties/test/commands/console_test.rb index 69e89d87ae..e047d4882d 100644 --- a/railties/test/commands/console_test.rb +++ b/railties/test/commands/console_test.rb @@ -58,8 +58,8 @@ class Rails::ConsoleTest < ActiveSupport::TestCase end def test_console_defaults_to_IRB - config = mock("config", :console => nil) - app = mock("app", :config => config) + config = mock("config", console: nil) + app = mock("app", config: config) app.expects(:load_console).returns(nil) assert_equal IRB, Rails::Console.new(app).console @@ -115,8 +115,8 @@ class Rails::ConsoleTest < ActiveSupport::TestCase def app @app ||= begin - config = mock("config", :console => FakeConsole) - app = mock("app", :config => config) + config = mock("config", console: FakeConsole) + app = mock("app", config: config) app.stubs(:sandbox=).returns(nil) app.expects(:load_console) app diff --git a/railties/test/fixtures/lib/plugin_builders/spec_builder.rb b/railties/test/fixtures/lib/plugin_builders/spec_builder.rb index aa18c7ddaa..2721429599 100644 --- a/railties/test/fixtures/lib/plugin_builders/spec_builder.rb +++ b/railties/test/fixtures/lib/plugin_builders/spec_builder.rb @@ -4,7 +4,7 @@ class PluginBuilder < Rails::PluginBuilder append_file "Rakefile", <<-EOF # spec tasks in rakefile -task :default => :spec +task default: :spec EOF end 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) } diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb index 027d8eb9b7..9953aa929b 100644 --- a/railties/test/generators_test.rb +++ b/railties/test/generators_test.rb @@ -43,8 +43,8 @@ class GeneratorsTest < Rails::Generators::TestCase end def test_invoke_with_config_values - Rails::Generators::ModelGenerator.expects(:start).with(["Account"], :behavior => :skip) - Rails::Generators.invoke :model, ["Account"], :behavior => :skip + Rails::Generators::ModelGenerator.expects(:start).with(["Account"], behavior: :skip) + Rails::Generators.invoke :model, ["Account"], behavior: :skip end def test_find_by_namespace @@ -165,7 +165,7 @@ class GeneratorsTest < Rails::Generators::TestCase end def test_developer_options_are_overwriten_by_user_options - Rails::Generators.options[:with_options] = { :generate => false } + Rails::Generators.options[:with_options] = { generate: false } self.class.class_eval(<<-end_eval, __FILE__, __LINE__ + 1) class WithOptionsGenerator < Rails::Generators::Base @@ -186,7 +186,7 @@ class GeneratorsTest < Rails::Generators::TestCase File.open(template, 'w'){ |f| f.write "empty" } capture(:stdout) do - Rails::Generators.invoke :model, ["user"], :destination_root => destination_root + Rails::Generators.invoke :model, ["user"], destination_root: destination_root end assert_file "app/models/user.rb" do |content| diff --git a/railties/test/initializable_test.rb b/railties/test/initializable_test.rb index c84c7f204c..16e259be5d 100644 --- a/railties/test/initializable_test.rb +++ b/railties/test/initializable_test.rb @@ -43,17 +43,17 @@ module InitializableTests class Child < Parent include Rails::Initializable - initializer :three, :before => :one do + initializer :three, before: :one do $arr << 3 end - initializer :four, :after => :one, :before => :two do + initializer :four, after: :one, before: :two do $arr << 4 end end class Parent - initializer :five, :before => :one do + initializer :five, before: :one do $arr << 5 end end @@ -61,7 +61,7 @@ module InitializableTests class Instance include Rails::Initializable - initializer :one, :group => :assets do + initializer :one, group: :assets do $arr << 1 end @@ -69,7 +69,7 @@ module InitializableTests $arr << 2 end - initializer :three, :group => :all do + initializer :three, group: :all do $arr << 3 end @@ -90,11 +90,11 @@ module InitializableTests class MoreInitializers include Rails::Initializable - initializer :startup, :before => :last do + initializer :startup, before: :last do $arr << 3 end - initializer :terminate, :after => :first, :before => :startup do + initializer :terminate, after: :first, before: :startup do $arr << two end @@ -134,11 +134,11 @@ module InitializableTests class PluginB include Rails::Initializable - initializer "plugin_b.startup", :after => "plugin_a.startup" do + initializer "plugin_b.startup", after: "plugin_a.startup" do $arr << 2 end - initializer "plugin_b.terminate", :before => "plugin_a.terminate" do + initializer "plugin_b.terminate", before: "plugin_a.terminate" do $arr << 3 end end diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 0f36eb67e5..e59488f97d 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -113,14 +113,14 @@ module TestHelpers routes = File.read("#{app_path}/config/routes.rb") if routes =~ /(\n\s*end\s*)\Z/ File.open("#{app_path}/config/routes.rb", 'w') do |f| - f.puts $` + "\nmatch ':controller(/:action(/:id))(.:format)', :via => :all\n" + $1 + f.puts $` + "\nmatch ':controller(/:action(/:id))(.:format)', via: :all\n" + $1 end end add_to_config <<-RUBY config.eager_load = false config.secret_token = "3b7cd727ee24e8444053437c36cc66c4" - config.session_store :cookie_store, :key => "_myapp_session" + config.session_store :cookie_store, key: "_myapp_session" config.active_support.deprecation = :log config.action_controller.allow_forgery_protection = false RUBY @@ -139,7 +139,7 @@ module TestHelpers app = Class.new(Rails::Application) app.config.eager_load = false app.config.secret_token = "3b7cd727ee24e8444053437c36cc66c4" - app.config.session_store :cookie_store, :key => "_myapp_session" + app.config.session_store :cookie_store, key: "_myapp_session" app.config.active_support.deprecation = :log yield app if block_given? @@ -157,7 +157,7 @@ module TestHelpers controller :foo, <<-RUBY class FooController < ApplicationController def index - render :text => "foo" + render text: "foo" end end RUBY diff --git a/railties/test/paths_test.rb b/railties/test/paths_test.rb index 76ff3ec3e4..12f18b9dbf 100644 --- a/railties/test/paths_test.rb +++ b/railties/test/paths_test.rb @@ -32,7 +32,7 @@ class PathsTest < ActiveSupport::TestCase end test "creating a root level path with options" do - @root.add "app", :with => "/foo/bar" + @root.add "app", with: "/foo/bar" assert_equal ["/foo/bar"], @root["app"].to_a end @@ -52,18 +52,18 @@ class PathsTest < ActiveSupport::TestCase test "creating a child level path with option" do @root.add "app" - @root.add "app/models", :with => "/foo/bar/baz" + @root.add "app/models", with: "/foo/bar/baz" assert_equal ["/foo/bar/baz"], @root["app/models"].to_a end test "child level paths are relative from the root" do @root.add "app" - @root.add "app/models", :with => "baz" + @root.add "app/models", with: "baz" assert_equal ["/foo/bar/baz"], @root["app/models"].to_a end test "adding multiple physical paths as an array" do - @root.add "app", :with => ["/app", "/app2"] + @root.add "app", with: ["/app", "/app2"] assert_equal ["/app", "/app2"], @root["app"].to_a end @@ -92,7 +92,7 @@ class PathsTest < ActiveSupport::TestCase end test "it is possible to add a path that should be autoloaded only once" do - @root.add "app", :with => "/app" + @root.add "app", with: "/app" @root["app"].autoload_once! assert @root["app"].autoload_once? assert @root.autoload_once.include?(@root["app"].expanded.first) @@ -109,13 +109,13 @@ class PathsTest < ActiveSupport::TestCase end test "it is possible to add a path without assignment and specify it should be loaded only once" do - @root.add "app", :with => "/app", :autoload_once => true + @root.add "app", with: "/app", autoload_once: true assert @root["app"].autoload_once? assert @root.autoload_once.include?("/app") end test "it is possible to add multiple paths without assignment and specify it should be loaded only once" do - @root.add "app", :with => ["/app", "/app2"], :autoload_once => true + @root.add "app", with: ["/app", "/app2"], autoload_once: true assert @root["app"].autoload_once? assert @root.autoload_once.include?("/app") assert @root.autoload_once.include?("/app2") @@ -153,20 +153,20 @@ class PathsTest < ActiveSupport::TestCase end test "it is possible to add a path without assignment and mark it as eager" do - @root.add "app", :with => "/app", :eager_load => true + @root.add "app", with: "/app", eager_load: true assert @root["app"].eager_load? assert @root.eager_load.include?("/app") end test "it is possible to add multiple paths without assignment and mark them as eager" do - @root.add "app", :with => ["/app", "/app2"], :eager_load => true + @root.add "app", with: ["/app", "/app2"], eager_load: true assert @root["app"].eager_load? assert @root.eager_load.include?("/app") assert @root.eager_load.include?("/app2") end test "it is possible to create a path without assignment and mark it both as eager and load once" do - @root.add "app", :with => "/app", :eager_load => true, :autoload_once => true + @root.add "app", with: "/app", eager_load: true, autoload_once: true assert @root["app"].eager_load? assert @root["app"].autoload_once? assert @root.eager_load.include?("/app") @@ -194,12 +194,12 @@ class PathsTest < ActiveSupport::TestCase end test "it should be possible to override a path's default glob without assignment" do - @root.add "app", :with => "/app", :glob => "*.rb" + @root.add "app", with: "/app", glob: "*.rb" assert_equal "*.rb", @root["app"].glob end test "it should be possible to replace a path and persist the original paths glob" do - @root.add "app", :glob => "*.rb" + @root.add "app", glob: "*.rb" @root["app"] = "app2" assert_equal ["/foo/bar/app2"], @root["app"].to_a assert_equal "*.rb", @root["app"].glob @@ -213,7 +213,7 @@ class PathsTest < ActiveSupport::TestCase end test "a path can be added to the load path on creation" do - @root.add "app", :with => "/app", :load_path => true + @root.add "app", with: "/app", load_path: true assert @root["app"].load_path? assert_equal ["/app"], @root.load_paths end @@ -226,7 +226,7 @@ class PathsTest < ActiveSupport::TestCase end test "a path can be marked as autoload on creation" do - @root.add "app", :with => "/app", :autoload => true + @root.add "app", with: "/app", autoload: true assert @root["app"].autoload? assert_equal ["/app"], @root.autoload_paths end diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb index cfb32b7d35..08fcddd4bf 100644 --- a/railties/test/rails_info_controller_test.rb +++ b/railties/test/rails_info_controller_test.rb @@ -21,19 +21,19 @@ class InfoControllerTest < ActionController::TestCase end test "info controller does not allow remote requests" do - @controller.stubs(:local_request? => false) + @controller.stubs(local_request?: false) get :properties assert_response :forbidden end test "info controller renders an error message when request was forbidden" do - @controller.stubs(:local_request? => false) + @controller.stubs(local_request?: false) get :properties assert_select 'p' end test "info controller allows requests when all requests are considered local" do - @controller.stubs(:local_request? => true) + @controller.stubs(local_request?: true) get :properties assert_response :success end diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index e52b3efdab..71bb34faf5 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -285,8 +285,8 @@ module RailtiesTest @plugin.write "config/routes.rb", <<-RUBY Rails.application.routes.draw do - get 'foo', :to => 'bar#index' - get 'bar', :to => 'bar#index' + get 'foo', to: 'bar#index' + get 'bar', to: 'bar#index' end RUBY @@ -366,7 +366,7 @@ YAML Rails.application.routes.draw do namespace :admin do namespace :foo do - get "bar", :to => "bar#index" + get "bar", to: "bar#index" end end end @@ -375,7 +375,7 @@ YAML @plugin.write "app/controllers/admin/foo/bar_controller.rb", <<-RUBY class Admin::Foo::BarController < ApplicationController def index - render :text => "Rendered from namespace" + render text: "Rendered from namespace" end end RUBY @@ -487,14 +487,14 @@ YAML controller "foo", <<-RUBY class FooController < ActionController::Base def index - render :text => params[:username] + render text: params[:username] end end RUBY @plugin.write "config/routes.rb", <<-RUBY Bukkits::Engine.routes.draw do - root :to => "foo#index" + root to: "foo#index" end RUBY @@ -608,14 +608,14 @@ YAML app_file "config/routes.rb", <<-RUBY AppTemplate::Application.routes.draw do - get "/bar" => "bar#index", :as => "bar" - mount Bukkits::Engine => "/bukkits", :as => "bukkits" + get "/bar" => "bar#index", as: "bar" + mount Bukkits::Engine => "/bukkits", as: "bukkits" end RUBY @plugin.write "config/routes.rb", <<-RUBY Bukkits::Engine.routes.draw do - get "/foo" => "foo#index", :as => "foo" + get "/foo" => "foo#index", as: "foo" get "/foo/show" => "foo#show" get "/from_app" => "foo#from_app" get "/routes_helpers_in_view" => "foo#routes_helpers_in_view" @@ -643,23 +643,23 @@ YAML @plugin.write "app/controllers/bukkits/foo_controller.rb", <<-RUBY class Bukkits::FooController < ActionController::Base def index - render :inline => "<%= help_the_engine %>" + render inline: "<%= help_the_engine %>" end def show - render :text => foo_path + render text: foo_path end def from_app - render :inline => "<%= (self.respond_to?(:bar_path) || self.respond_to?(:something)) %>" + render inline: "<%= (self.respond_to?(:bar_path) || self.respond_to?(:something)) %>" end def routes_helpers_in_view - render :inline => "<%= foo_path %>, <%= main_app.bar_path %>" + render :inline "<%= foo_path %>, <%= main_app.bar_path %>" end def polymorphic_path_without_namespace - render :text => polymorphic_path(Post.new) + render text: polymorphic_path(Post.new) end end RUBY @@ -726,7 +726,7 @@ YAML app_file "config/routes.rb", <<-RUBY AppTemplate::Application.routes.draw do - mount Bukkits::Engine => "/bukkits", :as => "bukkits" + mount Bukkits::Engine => "/bukkits", as: "bukkits" end RUBY @@ -1033,11 +1033,11 @@ YAML controller "main", <<-RUBY class MainController < ActionController::Base def foo - render :inline => '<%= render :partial => "shared/foo" %>' + render inline: '<%= render :partial => "shared/foo" %>' end def bar - render :inline => '<%= render :partial => "shared/bar" %>' + render inline: '<%= render :partial => "shared/bar" %>' end end RUBY @@ -1113,7 +1113,7 @@ YAML controller "main", <<-RUBY class MainController < ActionController::Base def foo - render :inline => '<%= render :partial => "shared/foo" %>' + render inline: '<%= render :partial => "shared/foo" %>' end end RUBY @@ -1167,7 +1167,7 @@ YAML fullpath: \#{request.fullpath} path: \#{request.path} TEXT - render :text => text + render text: text end end end @@ -1205,7 +1205,7 @@ YAML app_file "app/controllers/bar_controller.rb", <<-RUBY class BarController < ApplicationController def index - render :text => bukkits.bukkit_path + render text: bukkits.bukkit_path end end RUBY @@ -1227,7 +1227,7 @@ YAML @plugin.write "app/controllers/bukkits/bukkit_controller.rb", <<-RUBY class Bukkits::BukkitController < ActionController::Base def index - render :text => main_app.bar_path + render text: main_app.bar_path end end RUBY diff --git a/railties/test/railties/generators_test.rb b/railties/test/railties/generators_test.rb index c90b795d59..0abb2b7578 100644 --- a/railties/test/railties/generators_test.rb +++ b/railties/test/railties/generators_test.rb @@ -46,7 +46,7 @@ module RailtiesTests f.write <<-GEMFILE.gsub(/^ {12}/, '') source "http://rubygems.org" - gem 'rails', :path => '#{RAILS_FRAMEWORK_ROOT}' + gem 'rails', path: '#{RAILS_FRAMEWORK_ROOT}' gem 'sqlite3' GEMFILE end diff --git a/railties/test/railties/mounted_engine_test.rb b/railties/test/railties/mounted_engine_test.rb index bd13c3aba3..a1c52f01dc 100644 --- a/railties/test/railties/mounted_engine_test.rb +++ b/railties/test/railties/mounted_engine_test.rb @@ -42,14 +42,14 @@ module ApplicationTests @simple_plugin.write "config/routes.rb", <<-RUBY Weblog::Engine.routes.draw do - get '/weblog' => "weblogs#index", :as => 'weblogs' + get '/weblog' => "weblogs#index", as: 'weblogs' end RUBY @simple_plugin.write "app/controllers/weblogs_controller.rb", <<-RUBY class WeblogsController < ActionController::Base def index - render :text => request.url + render text: request.url end end RUBY @@ -86,9 +86,9 @@ module ApplicationTests @plugin.write "config/routes.rb", <<-RUBY Blog::Engine.routes.draw do resources :posts - get '/generate_application_route', :to => 'posts#generate_application_route' - get '/application_route_in_view', :to => 'posts#application_route_in_view' - get '/engine_polymorphic_path', :to => 'posts#engine_polymorphic_path' + get '/generate_application_route', to: 'posts#generate_application_route' + get '/application_route_in_view', to: 'posts#application_route_in_view' + get '/engine_polymorphic_path', to: 'posts#engine_polymorphic_path' end RUBY @@ -96,22 +96,22 @@ module ApplicationTests module Blog class PostsController < ActionController::Base def index - render :text => blog.post_path(1) + render text: blog.post_path(1) end def generate_application_route - path = main_app.url_for(:controller => "/main", - :action => "index", - :only_path => true) - render :text => path + path = main_app.url_for(controller: "/main", + action: "index", + only_path: true) + render text: path end def application_route_in_view - render :inline => "<%= main_app.root_path %>" + render inline: "<%= main_app.root_path %>" end def engine_polymorphic_path - render :text => polymorphic_path(Post.new) + render text: polymorphic_path(Post.new) end end end @@ -120,31 +120,31 @@ module ApplicationTests app_file "app/controllers/application_generating_controller.rb", <<-RUBY class ApplicationGeneratingController < ActionController::Base def engine_route - render :text => blog.posts_path + render text: blog.posts_path end def engine_route_in_view - render :inline => "<%= blog.posts_path %>" + render inline: "<%= blog.posts_path %>" end def weblog_engine_route - render :text => weblog.weblogs_path + render text: weblog.weblogs_path end def weblog_engine_route_in_view - render :inline => "<%= weblog.weblogs_path %>" + render inline: "<%= weblog.weblogs_path %>" end def url_for_engine_route - render :text => blog.url_for(:controller => "blog/posts", :action => "index", :user => "john", :only_path => true) + render text: blog.url_for(controller: "blog/posts", action: "index", user: "john", only_path: true) end def polymorphic_route - render :text => polymorphic_url([blog, Blog::Post.new]) + render text: polymorphic_url([blog, Blog::Post.new]) end def application_polymorphic_path - render :text => polymorphic_path(Blog::Post.new) + render text: polymorphic_path(Blog::Post.new) end end RUBY |