diff options
author | Xavier Noria <fxn@hashref.com> | 2016-08-06 18:03:25 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-08-06 18:10:53 +0200 |
commit | a731125f12c5834de7eae3455fad63ea4d348034 (patch) | |
tree | 0ada76c652c1a2a1fd68cdbecf5adc2df6beeb51 /activesupport/test/core_ext/object | |
parent | d66e7835bea9505f7003e5038aa19b6ea95ceea1 (diff) | |
download | rails-a731125f12c5834de7eae3455fad63ea4d348034.tar.gz rails-a731125f12c5834de7eae3455fad63ea4d348034.tar.bz2 rails-a731125f12c5834de7eae3455fad63ea4d348034.zip |
applies new string literal convention in activesupport/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
Diffstat (limited to 'activesupport/test/core_ext/object')
11 files changed, 88 insertions, 88 deletions
diff --git a/activesupport/test/core_ext/object/acts_like_test.rb b/activesupport/test/core_ext/object/acts_like_test.rb index e68b1d23cb..631f4e63a8 100644 --- a/activesupport/test/core_ext/object/acts_like_test.rb +++ b/activesupport/test/core_ext/object/acts_like_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'active_support/core_ext/object' +require "abstract_unit" +require "active_support/core_ext/object" class ObjectTests < ActiveSupport::TestCase class DuckTime diff --git a/activesupport/test/core_ext/object/blank_test.rb b/activesupport/test/core_ext/object/blank_test.rb index a142096993..ab0676524e 100644 --- a/activesupport/test/core_ext/object/blank_test.rb +++ b/activesupport/test/core_ext/object/blank_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'active_support/core_ext/object/blank' +require "abstract_unit" +require "active_support/core_ext/object/blank" class BlankTest < ActiveSupport::TestCase class EmptyTrue @@ -14,8 +14,8 @@ class BlankTest < ActiveSupport::TestCase end end - BLANK = [ EmptyTrue.new, nil, false, '', ' ', " \n\t \r ", ' ', "\u00a0", [], {} ] - NOT = [ EmptyFalse.new, Object.new, true, 0, 1, 'a', [nil], { nil => 0 } ] + BLANK = [ EmptyTrue.new, nil, false, "", " ", " \n\t \r ", " ", "\u00a0", [], {} ] + NOT = [ EmptyFalse.new, Object.new, true, 0, 1, "a", [nil], { nil => 0 } ] def test_blank BLANK.each { |v| assert_equal true, v.blank?, "#{v.inspect} should be blank" } diff --git a/activesupport/test/core_ext/object/deep_dup_test.rb b/activesupport/test/core_ext/object/deep_dup_test.rb index aa839201ea..38981f0497 100644 --- a/activesupport/test/core_ext/object/deep_dup_test.rb +++ b/activesupport/test/core_ext/object/deep_dup_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'active_support/core_ext/object' +require "abstract_unit" +require "active_support/core_ext/object" class DeepDupTest < ActiveSupport::TestCase @@ -12,11 +12,11 @@ class DeepDupTest < ActiveSupport::TestCase end def test_hash_deep_dup - hash = { :a => { :b => 'b' } } + hash = { :a => { :b => "b" } } dup = hash.deep_dup - dup[:a][:c] = 'c' + dup[:a][:c] = "c" assert_equal nil, hash[:a][:c] - assert_equal 'c', dup[:a][:c] + assert_equal "c", dup[:a][:c] end def test_array_deep_dup_with_hash_inside @@ -30,9 +30,9 @@ class DeepDupTest < ActiveSupport::TestCase def test_hash_deep_dup_with_array_inside hash = { :a => [1, 2] } dup = hash.deep_dup - dup[:a][2] = 'c' + dup[:a][2] = "c" assert_equal nil, hash[:a][2] - assert_equal 'c', dup[:a][2] + assert_equal "c", dup[:a][2] end def test_deep_dup_initialize diff --git a/activesupport/test/core_ext/object/duplicable_test.rb b/activesupport/test/core_ext/object/duplicable_test.rb index 042f5cfb34..2cbfefe235 100644 --- a/activesupport/test/core_ext/object/duplicable_test.rb +++ b/activesupport/test/core_ext/object/duplicable_test.rb @@ -1,12 +1,12 @@ -require 'abstract_unit' -require 'bigdecimal' -require 'active_support/core_ext/object/duplicable' -require 'active_support/core_ext/numeric/time' +require "abstract_unit" +require "bigdecimal" +require "active_support/core_ext/object/duplicable" +require "active_support/core_ext/numeric/time" class DuplicableTest < ActiveSupport::TestCase RAISE_DUP = [nil, false, true, :symbol, 1, 2.3, method(:puts)] - ALLOW_DUP = ['1', Object.new, /foo/, [], {}, Time.now, Class.new, Module.new] - ALLOW_DUP << BigDecimal.new('4.56') + ALLOW_DUP = ["1", Object.new, /foo/, [], {}, Time.now, Class.new, Module.new] + ALLOW_DUP << BigDecimal.new("4.56") def test_duplicable rubinius_skip "* Method#dup is allowed at the moment on Rubinius\n" \ diff --git a/activesupport/test/core_ext/object/inclusion_test.rb b/activesupport/test/core_ext/object/inclusion_test.rb index 32d512eca3..9258c46be5 100644 --- a/activesupport/test/core_ext/object/inclusion_test.rb +++ b/activesupport/test/core_ext/object/inclusion_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'active_support/core_ext/object/inclusion' +require "abstract_unit" +require "active_support/core_ext/object/inclusion" class InTest < ActiveSupport::TestCase def test_in_array diff --git a/activesupport/test/core_ext/object/instance_variables_test.rb b/activesupport/test/core_ext/object/instance_variables_test.rb index 9f4c5dc4f1..510352595a 100644 --- a/activesupport/test/core_ext/object/instance_variables_test.rb +++ b/activesupport/test/core_ext/object/instance_variables_test.rb @@ -1,11 +1,11 @@ -require 'abstract_unit' -require 'active_support/core_ext/object' +require "abstract_unit" +require "active_support/core_ext/object" class ObjectInstanceVariableTest < ActiveSupport::TestCase def setup @source, @dest = Object.new, Object.new - @source.instance_variable_set(:@bar, 'bar') - @source.instance_variable_set(:@baz, 'baz') + @source.instance_variable_set(:@bar, "bar") + @source.instance_variable_set(:@baz, "baz") end def test_instance_variable_names @@ -13,19 +13,19 @@ class ObjectInstanceVariableTest < ActiveSupport::TestCase end def test_instance_values - assert_equal({'bar' => 'bar', 'baz' => 'baz'}, @source.instance_values) + assert_equal({"bar" => "bar", "baz" => "baz"}, @source.instance_values) end def test_instance_exec_passes_arguments_to_block - assert_equal %w(hello goodbye), 'hello'.instance_exec('goodbye') { |v| [self, v] } + assert_equal %w(hello goodbye), "hello".instance_exec("goodbye") { |v| [self, v] } end def test_instance_exec_with_frozen_obj - assert_equal %w(olleh goodbye), 'hello'.freeze.instance_exec('goodbye') { |v| [reverse, v] } + assert_equal %w(olleh goodbye), "hello".freeze.instance_exec("goodbye") { |v| [reverse, v] } end def test_instance_exec_nested - assert_equal %w(goodbye olleh bar), 'hello'.instance_exec('goodbye') { |arg| - [arg] + instance_exec('bar') { |v| [reverse, v] } } + assert_equal %w(goodbye olleh bar), "hello".instance_exec("goodbye") { |arg| + [arg] + instance_exec("bar") { |v| [reverse, v] } } end end diff --git a/activesupport/test/core_ext/object/json_cherry_pick_test.rb b/activesupport/test/core_ext/object/json_cherry_pick_test.rb index 2f7ea3a497..dd4e90918e 100644 --- a/activesupport/test/core_ext/object/json_cherry_pick_test.rb +++ b/activesupport/test/core_ext/object/json_cherry_pick_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" # These test cases were added to test that cherry-picking the json extensions # works correctly, primarily for dependencies problems reported in #16131. They @@ -9,7 +9,7 @@ class JsonCherryPickTest < ActiveSupport::TestCase include ActiveSupport::Testing::Isolation def test_time_as_json - require_or_skip 'active_support/core_ext/object/json' + require_or_skip "active_support/core_ext/object/json" expected = Time.new(2004, 7, 25) actual = Time.parse(expected.as_json) @@ -18,7 +18,7 @@ class JsonCherryPickTest < ActiveSupport::TestCase end def test_date_as_json - require_or_skip 'active_support/core_ext/object/json' + require_or_skip "active_support/core_ext/object/json" expected = Date.new(2004, 7, 25) actual = Date.parse(expected.as_json) @@ -27,7 +27,7 @@ class JsonCherryPickTest < ActiveSupport::TestCase end def test_datetime_as_json - require_or_skip 'active_support/core_ext/object/json' + require_or_skip "active_support/core_ext/object/json" expected = DateTime.new(2004, 7, 25) actual = DateTime.parse(expected.as_json) diff --git a/activesupport/test/core_ext/object/json_gem_encoding_test.rb b/activesupport/test/core_ext/object/json_gem_encoding_test.rb index 2cbb1d590f..f5016d0c2a 100644 --- a/activesupport/test/core_ext/object/json_gem_encoding_test.rb +++ b/activesupport/test/core_ext/object/json_gem_encoding_test.rb @@ -1,6 +1,6 @@ -require 'abstract_unit' -require 'json' -require 'json/encoding_test_cases' +require "abstract_unit" +require "json" +require "json/encoding_test_cases" # These test cases were added to test that we do not interfere with json gem's # output when the AS encoder is loaded, primarily for problems reported in @@ -13,7 +13,7 @@ require 'json/encoding_test_cases' # we need to require this upfront to ensure we don't get a false failure, but # ideally we should just fix the BigDecimal core_ext to not change to_s without # arguments. -require 'active_support/core_ext/big_decimal' +require "active_support/core_ext/big_decimal" class JsonGemEncodingTest < ActiveSupport::TestCase include ActiveSupport::Testing::Isolation @@ -48,7 +48,7 @@ class JsonGemEncodingTest < ActiveSupport::TestCase exception = e end - require_or_skip 'active_support/core_ext/object/json' + require_or_skip "active_support/core_ext/object/json" if exception assert_raises_with_message JSON::GeneratorError, e.message do diff --git a/activesupport/test/core_ext/object/to_param_test.rb b/activesupport/test/core_ext/object/to_param_test.rb index 30a7557dc2..56246b24f3 100644 --- a/activesupport/test/core_ext/object/to_param_test.rb +++ b/activesupport/test/core_ext/object/to_param_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'active_support/core_ext/object/to_param' +require "abstract_unit" +require "active_support/core_ext/object/to_param" class ToParamTest < ActiveSupport::TestCase class CustomString < String @@ -10,8 +10,8 @@ class ToParamTest < ActiveSupport::TestCase def test_object foo = Object.new - def foo.to_s; 'foo' end - assert_equal 'foo', foo.to_param + def foo.to_s; "foo" end + assert_equal "foo", foo.to_param end def test_nil @@ -25,13 +25,13 @@ class ToParamTest < ActiveSupport::TestCase def test_array # Empty Array - assert_equal '', [].to_param + assert_equal "", [].to_param array = [1, 2, 3, 4] assert_equal "1/2/3/4", array.to_param # Array of different objects - array = [1, '3', { a: 1, b: 2 }, nil, true, false, CustomString.new('object')] + array = [1, "3", { a: 1, b: 2 }, nil, true, false, CustomString.new("object")] assert_equal "1/3/a=1&b=2//true/false/custom-object", array.to_param end end diff --git a/activesupport/test/core_ext/object/to_query_test.rb b/activesupport/test/core_ext/object/to_query_test.rb index 09cab3ed35..42566d5374 100644 --- a/activesupport/test/core_ext/object/to_query_test.rb +++ b/activesupport/test/core_ext/object/to_query_test.rb @@ -1,82 +1,82 @@ -require 'abstract_unit' -require 'active_support/ordered_hash' -require 'active_support/core_ext/object/to_query' -require 'active_support/core_ext/string/output_safety' +require "abstract_unit" +require "active_support/ordered_hash" +require "active_support/core_ext/object/to_query" +require "active_support/core_ext/string/output_safety" class ToQueryTest < ActiveSupport::TestCase def test_simple_conversion - assert_query_equal 'a=10', :a => 10 + assert_query_equal "a=10", :a => 10 end def test_cgi_escaping - assert_query_equal 'a%3Ab=c+d', 'a:b' => 'c d' + assert_query_equal "a%3Ab=c+d", "a:b" => "c d" end def test_html_safe_parameter_key - assert_query_equal 'a%3Ab=c+d', 'a:b'.html_safe => 'c d' + assert_query_equal "a%3Ab=c+d", "a:b".html_safe => "c d" end def test_html_safe_parameter_value - assert_query_equal 'a=%5B10%5D', 'a' => '[10]'.html_safe + assert_query_equal "a=%5B10%5D", "a" => "[10]".html_safe end def test_nil_parameter_value empty = Object.new def empty.to_param; nil end - assert_query_equal 'a=', 'a' => empty + assert_query_equal "a=", "a" => empty end def test_nested_conversion - assert_query_equal 'person%5Blogin%5D=seckar&person%5Bname%5D=Nicholas', - :person => Hash[:login, 'seckar', :name, 'Nicholas'] + assert_query_equal "person%5Blogin%5D=seckar&person%5Bname%5D=Nicholas", + :person => Hash[:login, "seckar", :name, "Nicholas"] end def test_multiple_nested - assert_query_equal 'account%5Bperson%5D%5Bid%5D=20&person%5Bid%5D=10', + assert_query_equal "account%5Bperson%5D%5Bid%5D=20&person%5Bid%5D=10", Hash[:account, {:person => {:id => 20}}, :person, {:id => 10}] end def test_array_values - assert_query_equal 'person%5Bid%5D%5B%5D=10&person%5Bid%5D%5B%5D=20', + assert_query_equal "person%5Bid%5D%5B%5D=10&person%5Bid%5D%5B%5D=20", :person => {:id => [10, 20]} end def test_array_values_are_not_sorted - assert_query_equal 'person%5Bid%5D%5B%5D=20&person%5Bid%5D%5B%5D=10', + assert_query_equal "person%5Bid%5D%5B%5D=20&person%5Bid%5D%5B%5D=10", :person => {:id => [20, 10]} end def test_empty_array - assert_equal "person%5B%5D=", [].to_query('person') + assert_equal "person%5B%5D=", [].to_query("person") end def test_nested_empty_hash - assert_equal '', + assert_equal "", {}.to_query - assert_query_equal 'a=1&b%5Bc%5D=3', + assert_query_equal "a=1&b%5Bc%5D=3", { a: 1, b: { c: 3, d: {} } } - assert_query_equal '', + assert_query_equal "", { 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: '' } } - assert_query_equal 'b%5Bc%5D=3&b%5Bf%5D=', - { b: { c: 3, k: {}, f: '' } } - assert_query_equal 'b=3', + assert_query_equal "b%5Bc%5D=false&b%5Be%5D=&b%5Bf%5D=&p=12", + { p: 12, b: { c: false, e: nil, f: "" } } + assert_query_equal "b%5Bc%5D=3&b%5Bf%5D=", + { b: { c: 3, k: {}, f: "" } } + assert_query_equal "b=3", {a: [], b: 3} end def test_hash_with_namespace - hash = { name: 'Nakshay', nationality: 'Indian' } - assert_equal "user%5Bname%5D=Nakshay&user%5Bnationality%5D=Indian", hash.to_query('user') + hash = { name: "Nakshay", nationality: "Indian" } + assert_equal "user%5Bname%5D=Nakshay&user%5Bnationality%5D=Indian", hash.to_query("user") end def test_hash_sorted_lexicographically - hash = { type: 'human', name: 'Nakshay' } + hash = { type: "human", name: "Nakshay" } assert_equal "name=Nakshay&type=human", hash.to_query end private def assert_query_equal(expected, actual) - assert_equal expected.split('&'), actual.to_query.split('&') + assert_equal expected.split("&"), actual.to_query.split("&") end end diff --git a/activesupport/test/core_ext/object/try_test.rb b/activesupport/test/core_ext/object/try_test.rb index 25bf0207b8..5c8bf59952 100644 --- a/activesupport/test/core_ext/object/try_test.rb +++ b/activesupport/test/core_ext/object/try_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'active_support/core_ext/object' +require "abstract_unit" +require "active_support/core_ext/object" class ObjectTryTest < ActiveSupport::TestCase def setup @@ -15,7 +15,7 @@ class ObjectTryTest < ActiveSupport::TestCase def test_nonexisting_method_with_arguments method = :undefined_method assert !@string.respond_to?(method) - assert_nil @string.try(method, 'llo', 'y') + assert_nil @string.try(method, "llo", "y") end def test_nonexisting_method_bang @@ -27,7 +27,7 @@ class ObjectTryTest < ActiveSupport::TestCase def test_nonexisting_method_with_arguments_bang method = :undefined_method assert !@string.respond_to?(method) - assert_raise(NoMethodError) { @string.try!(method, 'llo', 'y') } + assert_raise(NoMethodError) { @string.try!(method, "llo", "y") } end def test_valid_method @@ -35,11 +35,11 @@ class ObjectTryTest < ActiveSupport::TestCase end def test_argument_forwarding - assert_equal 'Hey', @string.try(:sub, 'llo', 'y') + assert_equal "Hey", @string.try(:sub, "llo", "y") end def test_block_forwarding - assert_equal 'Hey', @string.try(:sub, 'llo') { |match| 'y' } + assert_equal "Hey", @string.try(:sub, "llo") { |match| "y" } end def test_nil_to_type @@ -48,7 +48,7 @@ class ObjectTryTest < ActiveSupport::TestCase end def test_false_try - assert_equal 'false', false.try(:to_s) + assert_equal "false", false.try(:to_s) end def test_try_only_block @@ -78,7 +78,7 @@ class ObjectTryTest < ActiveSupport::TestCase private def private_method - 'private method' + "private method" end end @@ -90,7 +90,7 @@ class ObjectTryTest < ActiveSupport::TestCase private def private_method - 'private method' + "private method" end end @@ -99,22 +99,22 @@ class ObjectTryTest < ActiveSupport::TestCase class Decorator < SimpleDelegator def delegator_method - 'delegator method' + "delegator method" end def reverse - 'overridden reverse' + "overridden reverse" end private def private_delegator_method - 'private delegator method' + "private delegator method" end end def test_try_with_method_on_delegator - assert_equal 'delegator method', Decorator.new(@string).try(:delegator_method) + assert_equal "delegator method", Decorator.new(@string).try(:delegator_method) end def test_try_with_method_on_delegator_target @@ -122,7 +122,7 @@ class ObjectTryTest < ActiveSupport::TestCase end def test_try_with_overridden_method_on_delegator - assert_equal 'overridden reverse', Decorator.new(@string).reverse + assert_equal "overridden reverse", Decorator.new(@string).reverse end def test_try_with_private_method_on_delegator @@ -140,7 +140,7 @@ class ObjectTryTest < ActiveSupport::TestCase private def private_method - 'private method' + "private method" end end @@ -152,7 +152,7 @@ class ObjectTryTest < ActiveSupport::TestCase private def private_method - 'private method' + "private method" end end |