From 411ccbdab2608c62aabdb320d52cb02d446bb39c Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 6 Aug 2016 19:44:11 +0200 Subject: remove redundant curlies from hash arguments --- activesupport/test/caching_test.rb | 6 ++--- activesupport/test/core_ext/duration_test.rb | 2 +- .../test/core_ext/hash/transform_keys_test.rb | 2 +- activesupport/test/core_ext/hash_ext_test.rb | 22 ++++++++--------- .../test/core_ext/object/to_query_test.rb | 10 ++++---- activesupport/test/json/encoding_test_cases.rb | 2 +- activesupport/test/message_encryptor_test.rb | 2 +- activesupport/test/message_verifier_test.rb | 2 +- activesupport/test/number_helper_i18n_test.rb | 2 +- activesupport/test/number_helper_test.rb | 28 +++++++++++----------- activesupport/test/xml_mini_test.rb | 2 +- 11 files changed, 40 insertions(+), 40 deletions(-) (limited to 'activesupport/test') diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index be1f93a0b2..422b7f0834 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -305,7 +305,7 @@ module CacheStoreBehavior end def test_should_read_and_write_hash - assert @cache.write("foo", {a: "b"}) + assert @cache.write("foo", a: "b") assert_equal({a: "b"}, @cache.read("foo")) end @@ -1173,7 +1173,7 @@ class CacheStoreLoggerTest < ActiveSupport::TestCase end def test_log_with_string_namespace - @cache.fetch("foo", {namespace: "string_namespace"}) { "bar" } + @cache.fetch("foo", namespace: "string_namespace") { "bar" } assert_match %r{string_namespace:foo}, @buffer.string end @@ -1181,7 +1181,7 @@ class CacheStoreLoggerTest < ActiveSupport::TestCase proc = Proc.new do "proc_namespace" end - @cache.fetch("foo", {namespace: proc}) { "bar" } + @cache.fetch("foo", namespace: proc) { "bar" } assert_match %r{proc_namespace:foo}, @buffer.string end diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index d24a561be8..64b5bca151 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -74,7 +74,7 @@ class DurationTest < ActiveSupport::TestCase def test_inspect_locale current_locale = I18n.default_locale I18n.default_locale = :de - I18n.backend.store_translations(:de, { support: { array: { last_word_connector: " und " } } }) + I18n.backend.store_translations(:de, support: { array: { last_word_connector: " und " } }) assert_equal "10 years, 1 month und 1 day", (10.years + 1.month + 1.day).inspect ensure I18n.default_locale = current_locale diff --git a/activesupport/test/core_ext/hash/transform_keys_test.rb b/activesupport/test/core_ext/hash/transform_keys_test.rb index af91a79415..ea34a47b3d 100644 --- a/activesupport/test/core_ext/hash/transform_keys_test.rb +++ b/activesupport/test/core_ext/hash/transform_keys_test.rb @@ -52,7 +52,7 @@ class TransformKeysTest < ActiveSupport::TestCase end end - original = HashDescendant.new({ a: "a", b: "b" }) + original = HashDescendant.new(a: "a", b: "b") mapped = original.transform_keys { |k| "#{k}!".to_sym } assert_equal({ a: "a", b: "b" }, original) diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 1253c13c5a..8a9f33ae53 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -111,7 +111,7 @@ class HashExtTest < ActiveSupport::TestCase transformed_hash = @mixed.dup transformed_hash.transform_keys!{ |key| key.to_s.upcase } assert_equal @upcase_strings, transformed_hash - assert_equal @mixed, { :a => 1, "b" => 2 } + assert_equal @mixed, :a => 1, "b" => 2 end def test_deep_transform_keys! @@ -127,7 +127,7 @@ class HashExtTest < ActiveSupport::TestCase transformed_hash = @nested_mixed.deep_dup transformed_hash.deep_transform_keys!{ |key| key.to_s.upcase } assert_equal @nested_upcase_strings, transformed_hash - assert_equal @nested_mixed, { "a" => { b: { "c" => 3 } } } + assert_equal @nested_mixed, "a" => { b: { "c" => 3 } } end def test_symbolize_keys @@ -167,7 +167,7 @@ class HashExtTest < ActiveSupport::TestCase transformed_hash = @mixed.dup transformed_hash.deep_symbolize_keys! assert_equal @symbols, transformed_hash - assert_equal @mixed, { :a => 1, "b" => 2 } + assert_equal @mixed, :a => 1, "b" => 2 end def test_deep_symbolize_keys! @@ -183,7 +183,7 @@ class HashExtTest < ActiveSupport::TestCase transformed_hash = @nested_mixed.deep_dup transformed_hash.deep_symbolize_keys! assert_equal @nested_symbols, transformed_hash - assert_equal @nested_mixed, { "a" => { b: { "c" => 3 } } } + assert_equal @nested_mixed, "a" => { b: { "c" => 3 } } end def test_symbolize_keys_preserves_keys_that_cant_be_symbolized @@ -243,7 +243,7 @@ class HashExtTest < ActiveSupport::TestCase transformed_hash = @mixed.dup transformed_hash.stringify_keys! assert_equal @strings, transformed_hash - assert_equal @mixed, { :a => 1, "b" => 2 } + assert_equal @mixed, :a => 1, "b" => 2 end def test_deep_stringify_keys! @@ -259,7 +259,7 @@ class HashExtTest < ActiveSupport::TestCase transformed_hash = @nested_mixed.deep_dup transformed_hash.deep_stringify_keys! assert_equal @nested_strings, transformed_hash - assert_equal @nested_mixed, { "a" => { b: { "c" => 3 } } } + assert_equal @nested_mixed, "a" => { b: { "c" => 3 } } end def test_symbolize_keys_for_hash_with_indifferent_access @@ -447,7 +447,7 @@ class HashExtTest < ActiveSupport::TestCase def test_update_with_to_hash_conversion hash = HashWithIndifferentAccess.new - hash.update HashByConversion.new({ a: 1 }) + hash.update HashByConversion.new(a: 1) assert_equal hash["a"], 1 end @@ -472,7 +472,7 @@ class HashExtTest < ActiveSupport::TestCase def test_merge_with_to_hash_conversion hash = HashWithIndifferentAccess.new - merged = hash.merge HashByConversion.new({ a: 1 }) + merged = hash.merge HashByConversion.new(a: 1) assert_equal merged["a"], 1 end @@ -676,7 +676,7 @@ class HashExtTest < ActiveSupport::TestCase end def test_to_options_on_indifferent_preserves_works_as_hash_with_dup - h = HashWithIndifferentAccess.new({ a: { b: "b" } }) + h = HashWithIndifferentAccess.new(a: { b: "b" }) dup = h.dup dup[:a][:c] = "c" @@ -777,8 +777,8 @@ class HashExtTest < ActiveSupport::TestCase end def test_deep_merge_on_indifferent_access - hash_1 = HashWithIndifferentAccess.new({ a: "a", b: "b", c: { c1: "c1", c2: "c2", c3: { d1: "d1" } } }) - hash_2 = HashWithIndifferentAccess.new({ a: 1, c: { c1: 2, c3: { d2: "d2" } } }) + hash_1 = HashWithIndifferentAccess.new(a: "a", b: "b", c: { c1: "c1", c2: "c2", c3: { d1: "d1" } }) + hash_2 = HashWithIndifferentAccess.new(a: 1, c: { c1: 2, c3: { d2: "d2" } }) hash_3 = { a: 1, c: { c1: 2, c3: { d2: "d2" } } } expected = { "a" => 1, "b" => "b", "c" => { "c1" => 2, "c2" => "c2", "c3" => { "d1" => "d1", "d2" => "d2" } } } assert_equal expected, hash_1.deep_merge(hash_2) diff --git a/activesupport/test/core_ext/object/to_query_test.rb b/activesupport/test/core_ext/object/to_query_test.rb index aaa7e69acb..2eff475274 100644 --- a/activesupport/test/core_ext/object/to_query_test.rb +++ b/activesupport/test/core_ext/object/to_query_test.rb @@ -54,15 +54,15 @@ class ToQueryTest < ActiveSupport::TestCase assert_equal "", {}.to_query assert_query_equal "a=1&b%5Bc%5D=3", - { a: 1, b: { c: 3, d: {} } } + a: 1, b: { c: 3, d: {} } assert_query_equal "", - { a: {b: {c: {}}} } + a: {b: {c: {}}} assert_query_equal "b%5Bc%5D=false&b%5Be%5D=&b%5Bf%5D=&p=12", - { p: 12, b: { c: false, e: nil, f: "" } } + p: 12, b: { c: false, e: nil, f: "" } assert_query_equal "b%5Bc%5D=3&b%5Bf%5D=", - { b: { c: 3, k: {}, f: "" } } + b: { c: 3, k: {}, f: "" } assert_query_equal "b=3", - {a: [], b: 3} + a: [], b: 3 end def test_hash_with_namespace diff --git a/activesupport/test/json/encoding_test_cases.rb b/activesupport/test/json/encoding_test_cases.rb index ac0e2b2b05..f8c44f314f 100644 --- a/activesupport/test/json/encoding_test_cases.rb +++ b/activesupport/test/json/encoding_test_cases.rb @@ -70,7 +70,7 @@ module JSONTest [ Custom.new(nil), "null" ], [ Custom.new(:a), '"a"' ], [ Custom.new([ :foo, "bar" ]), '["foo","bar"]' ], - [ Custom.new({ foo: "hello", bar: "world" }), '{"bar":"world","foo":"hello"}' ], + [ Custom.new(foo: "hello", bar: "world"), '{"bar":"world","foo":"hello"}' ], [ Custom.new(Hashlike.new), '{"bar":"world","foo":"hello"}' ], [ Custom.new(Custom.new(Custom.new(:a))), '"a"' ]] diff --git a/activesupport/test/message_encryptor_test.rb b/activesupport/test/message_encryptor_test.rb index 3d9f90f1cc..a4976fa1ea 100644 --- a/activesupport/test/message_encryptor_test.rb +++ b/activesupport/test/message_encryptor_test.rb @@ -52,7 +52,7 @@ class MessageEncryptorTest < ActiveSupport::TestCase prev = ActiveSupport.use_standard_json_time_format ActiveSupport.use_standard_json_time_format = true encryptor = ActiveSupport::MessageEncryptor.new(SecureRandom.random_bytes(32), SecureRandom.random_bytes(128), serializer: JSONSerializer.new) - message = encryptor.encrypt_and_sign({ :foo => 123, "bar" => Time.utc(2010) }) + message = encryptor.encrypt_and_sign(:foo => 123, "bar" => Time.utc(2010)) exp = { "foo" => 123, "bar" => "2010-01-01T00:00:00.000Z" } assert_equal exp, encryptor.decrypt_and_verify(message) ensure diff --git a/activesupport/test/message_verifier_test.rb b/activesupport/test/message_verifier_test.rb index 3cea0c71cc..a29727608d 100644 --- a/activesupport/test/message_verifier_test.rb +++ b/activesupport/test/message_verifier_test.rb @@ -50,7 +50,7 @@ class MessageVerifierTest < ActiveSupport::TestCase prev = ActiveSupport.use_standard_json_time_format ActiveSupport.use_standard_json_time_format = true verifier = ActiveSupport::MessageVerifier.new("Hey, I'm a secret!", serializer: JSONSerializer.new) - message = verifier.generate({ :foo => 123, "bar" => Time.utc(2010) }) + message = verifier.generate(:foo => 123, "bar" => Time.utc(2010)) exp = { "foo" => 123, "bar" => "2010-01-01T00:00:00.000Z" } assert_equal exp, verifier.verified(message) assert_equal exp, verifier.verify(message) diff --git a/activesupport/test/number_helper_i18n_test.rb b/activesupport/test/number_helper_i18n_test.rb index f9d6dcf7b2..32e6e22525 100644 --- a/activesupport/test/number_helper_i18n_test.rb +++ b/activesupport/test/number_helper_i18n_test.rb @@ -60,7 +60,7 @@ module ActiveSupport def test_locale_default_format_has_precedence_over_helper_defaults I18n.backend.store_translations "ts", - { number: { format: { separator: ";" } } } + number: { format: { separator: ";" } } assert_equal("&$ - 10;00", number_to_currency(10, locale: "ts")) end diff --git a/activesupport/test/number_helper_test.rb b/activesupport/test/number_helper_test.rb index fd566f8d21..c25a3dedf7 100644 --- a/activesupport/test/number_helper_test.rb +++ b/activesupport/test/number_helper_test.rb @@ -46,10 +46,10 @@ module ActiveSupport [@instance_with_helpers, TestClassWithClassNumberHelpers, ActiveSupport::NumberHelper].each do |number_helper| assert_equal("555-1234", number_helper.number_to_phone(5551234)) assert_equal("800-555-1212", number_helper.number_to_phone(8005551212)) - assert_equal("(800) 555-1212", number_helper.number_to_phone(8005551212, {area_code: true})) - assert_equal("", number_helper.number_to_phone("", {area_code: true})) - assert_equal("800 555 1212", number_helper.number_to_phone(8005551212, {delimiter: " "})) - assert_equal("(800) 555-1212 x 123", number_helper.number_to_phone(8005551212, {area_code: true, extension: 123})) + assert_equal("(800) 555-1212", number_helper.number_to_phone(8005551212, area_code: true)) + assert_equal("", number_helper.number_to_phone("", area_code: true)) + assert_equal("800 555 1212", number_helper.number_to_phone(8005551212, delimiter: " ")) + assert_equal("(800) 555-1212 x 123", number_helper.number_to_phone(8005551212, area_code: true, extension: 123)) assert_equal("800-555-1212", number_helper.number_to_phone(8005551212, extension: " ")) assert_equal("555.1212", number_helper.number_to_phone(5551212, delimiter: ".")) assert_equal("800-555-1212", number_helper.number_to_phone("8005551212")) @@ -67,23 +67,23 @@ module ActiveSupport assert_equal("$1,234,567,890.50", number_helper.number_to_currency(1234567890.50)) assert_equal("$1,234,567,890.51", number_helper.number_to_currency(1234567890.506)) assert_equal("-$1,234,567,890.50", number_helper.number_to_currency(-1234567890.50)) - assert_equal("-$ 1,234,567,890.50", number_helper.number_to_currency(-1234567890.50, {format: "%u %n"})) - assert_equal("($1,234,567,890.50)", number_helper.number_to_currency(-1234567890.50, {negative_format: "(%u%n)"})) - assert_equal("$1,234,567,892", number_helper.number_to_currency(1234567891.50, {precision: 0})) - assert_equal("$1,234,567,890.5", number_helper.number_to_currency(1234567890.50, {precision: 1})) - assert_equal("£1234567890,50", number_helper.number_to_currency(1234567890.50, {unit: "£", separator: ",", delimiter: ""})) + assert_equal("-$ 1,234,567,890.50", number_helper.number_to_currency(-1234567890.50, format: "%u %n")) + assert_equal("($1,234,567,890.50)", number_helper.number_to_currency(-1234567890.50, negative_format: "(%u%n)")) + assert_equal("$1,234,567,892", number_helper.number_to_currency(1234567891.50, precision: 0)) + assert_equal("$1,234,567,890.5", number_helper.number_to_currency(1234567890.50, precision: 1)) + assert_equal("£1234567890,50", number_helper.number_to_currency(1234567890.50, unit: "£", separator: ",", delimiter: "")) assert_equal("$1,234,567,890.50", number_helper.number_to_currency("1234567890.50")) - assert_equal("1,234,567,890.50 Kč", number_helper.number_to_currency("1234567890.50", {unit: "Kč", format: "%n %u"})) - assert_equal("1,234,567,890.50 - Kč", number_helper.number_to_currency("-1234567890.50", {unit: "Kč", format: "%n %u", negative_format: "%n - %u"})) - assert_equal("0.00", number_helper.number_to_currency(+0.0, {unit: "", negative_format: "(%n)"})) + assert_equal("1,234,567,890.50 Kč", number_helper.number_to_currency("1234567890.50", unit: "Kč", format: "%n %u")) + assert_equal("1,234,567,890.50 - Kč", number_helper.number_to_currency("-1234567890.50", unit: "Kč", format: "%n %u", negative_format: "%n - %u")) + assert_equal("0.00", number_helper.number_to_currency(+0.0, unit: "", negative_format: "(%n)")) end end def test_number_to_percentage [@instance_with_helpers, TestClassWithClassNumberHelpers, ActiveSupport::NumberHelper].each do |number_helper| assert_equal("100.000%", number_helper.number_to_percentage(100)) - assert_equal("100%", number_helper.number_to_percentage(100, {precision: 0})) - assert_equal("302.06%", number_helper.number_to_percentage(302.0574, {precision: 2})) + assert_equal("100%", number_helper.number_to_percentage(100, precision: 0)) + assert_equal("302.06%", number_helper.number_to_percentage(302.0574, precision: 2)) assert_equal("100.000%", number_helper.number_to_percentage("100")) assert_equal("1000.000%", number_helper.number_to_percentage("1000")) assert_equal("123.4%", number_helper.number_to_percentage(123.400, precision: 3, strip_insignificant_zeros: true)) diff --git a/activesupport/test/xml_mini_test.rb b/activesupport/test/xml_mini_test.rb index 77b6d6df8f..2d79e71343 100644 --- a/activesupport/test/xml_mini_test.rb +++ b/activesupport/test/xml_mini_test.rb @@ -322,7 +322,7 @@ YAML } parser = @parsing["yaml"] assert_equal(expected, parser.call(yaml)) - assert_equal({1 => "test"}, parser.call({1 => "test"})) + assert_equal({1 => "test"}, parser.call(1 => "test")) assert_equal({"1 => 'test'"=>nil}, parser.call("{1 => 'test'}")) end -- cgit v1.2.3