aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/option_merger_test.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-08-06 19:38:33 +0200
committerXavier Noria <fxn@hashref.com>2016-08-06 19:38:33 +0200
commit5c315a8fa6296904f5e0ba8da919fc395548cf98 (patch)
treec20da9c73b5db9caa8c2aa711955ed17f01d396d /activesupport/test/option_merger_test.rb
parentd22e522179c1c90e658c3ed0e9b972ec62306209 (diff)
downloadrails-5c315a8fa6296904f5e0ba8da919fc395548cf98.tar.gz
rails-5c315a8fa6296904f5e0ba8da919fc395548cf98.tar.bz2
rails-5c315a8fa6296904f5e0ba8da919fc395548cf98.zip
modernizes hash syntax in activesupport
Diffstat (limited to 'activesupport/test/option_merger_test.rb')
-rw-r--r--activesupport/test/option_merger_test.rb26
1 files changed, 13 insertions, 13 deletions
diff --git a/activesupport/test/option_merger_test.rb b/activesupport/test/option_merger_test.rb
index 94870cebed..2bac550452 100644
--- a/activesupport/test/option_merger_test.rb
+++ b/activesupport/test/option_merger_test.rb
@@ -3,11 +3,11 @@ require "active_support/core_ext/object/with_options"
class OptionMergerTest < ActiveSupport::TestCase
def setup
- @options = {:hello => "world"}
+ @options = {hello: "world"}
end
def test_method_with_options_merges_options_when_options_are_present
- local_options = {:cool => true}
+ local_options = {cool: true}
with_options(@options) do |o|
assert_equal local_options, method_with_options(local_options)
@@ -24,7 +24,7 @@ class OptionMergerTest < ActiveSupport::TestCase
end
def test_method_with_options_allows_to_overwrite_options
- local_options = {:hello => "moon"}
+ local_options = {hello: "moon"}
assert_equal @options.keys, local_options.keys
with_options(@options) do |o|
@@ -40,34 +40,34 @@ class OptionMergerTest < ActiveSupport::TestCase
end
def test_nested_method_with_options_containing_hashes_merge
- with_options :conditions => { :method => :get } do |outer|
- outer.with_options :conditions => { :domain => "www" } do |inner|
- expected = { :conditions => { :method => :get, :domain => "www" } }
+ with_options conditions: { method: :get } do |outer|
+ outer.with_options conditions: { domain: "www" } do |inner|
+ expected = { conditions: { method: :get, domain: "www" } }
assert_equal expected, inner.method_with_options
end
end
end
def test_nested_method_with_options_containing_hashes_overwrite
- with_options :conditions => { :method => :get, :domain => "www" } do |outer|
- outer.with_options :conditions => { :method => :post } do |inner|
- expected = { :conditions => { :method => :post, :domain => "www" } }
+ with_options conditions: { method: :get, domain: "www" } do |outer|
+ outer.with_options conditions: { method: :post } do |inner|
+ expected = { conditions: { method: :post, domain: "www" } }
assert_equal expected, inner.method_with_options
end
end
end
def test_nested_method_with_options_containing_hashes_going_deep
- with_options :html => { :class => "foo", :style => { :margin => 0, :display => "block" } } do |outer|
- outer.with_options :html => { :title => "bar", :style => { :margin => "1em", :color => "#fff" } } do |inner|
- expected = { :html => { :class => "foo", :title => "bar", :style => { :margin => "1em", :display => "block", :color => "#fff" } } }
+ with_options html: { class: "foo", style: { margin: 0, display: "block" } } do |outer|
+ outer.with_options html: { title: "bar", style: { margin: "1em", color: "#fff" } } do |inner|
+ expected = { html: { class: "foo", title: "bar", style: { margin: "1em", display: "block", color: "#fff" } } }
assert_equal expected, inner.method_with_options
end
end
end
def test_nested_method_with_options_using_lambda
- local_lambda = lambda { { :lambda => true } }
+ local_lambda = lambda { { lambda: true } }
with_options(@options) do |o|
assert_equal @options.merge(local_lambda.call),
o.method_with_options(local_lambda).call