diff options
Diffstat (limited to 'activesupport/test/core_ext/object')
11 files changed, 168 insertions, 136 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..31241caf0a 100644 --- a/activesupport/test/core_ext/object/acts_like_test.rb +++ b/activesupport/test/core_ext/object/acts_like_test.rb @@ -1,5 +1,7 @@ -require 'abstract_unit' -require 'active_support/core_ext/object' +# frozen_string_literal: true + +require "abstract_unit" +require "active_support/core_ext/object" class ObjectTests < ActiveSupport::TestCase class DuckTime @@ -15,19 +17,19 @@ class ObjectTests < ActiveSupport::TestCase dt = DateTime.new duck = DuckTime.new - assert !object.acts_like?(:time) - assert !object.acts_like?(:date) + assert_not object.acts_like?(:time) + assert_not object.acts_like?(:date) assert time.acts_like?(:time) - assert !time.acts_like?(:date) + assert_not time.acts_like?(:date) - assert !date.acts_like?(:time) + assert_not date.acts_like?(:time) assert date.acts_like?(:date) assert dt.acts_like?(:time) assert dt.acts_like?(:date) assert duck.acts_like?(:time) - assert !duck.acts_like?(:date) + assert_not duck.acts_like?(:date) end end diff --git a/activesupport/test/core_ext/object/blank_test.rb b/activesupport/test/core_ext/object/blank_test.rb index 8a5e385dd7..954f415383 100644 --- a/activesupport/test/core_ext/object/blank_test.rb +++ b/activesupport/test/core_ext/object/blank_test.rb @@ -1,6 +1,7 @@ +# frozen_string_literal: true -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 @@ -15,8 +16,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", [], {}, " ".encode("UTF-16LE") ] + NOT = [ EmptyFalse.new, Object.new, true, 0, 1, "a", [nil], { nil => 0 }, Time.now, "my value".encode("UTF-16LE") ] def test_blank BLANK.each { |v| assert_equal true, v.blank?, "#{v.inspect} should be blank" } @@ -29,7 +30,7 @@ class BlankTest < ActiveSupport::TestCase end def test_presence - BLANK.each { |v| assert_equal nil, v.presence, "#{v.inspect}.presence should return nil" } + BLANK.each { |v| assert_nil v.presence, "#{v.inspect}.presence should return nil" } NOT.each { |v| assert_equal v, v.presence, "#{v.inspect}.presence should return self" } end end diff --git a/activesupport/test/core_ext/object/deep_dup_test.rb b/activesupport/test/core_ext/object/deep_dup_test.rb index 791b5e7172..1fb26ebac7 100644 --- a/activesupport/test/core_ext/object/deep_dup_test.rb +++ b/activesupport/test/core_ext/object/deep_dup_test.rb @@ -1,43 +1,44 @@ -require 'abstract_unit' -require 'active_support/core_ext/object' +# frozen_string_literal: true -class DeepDupTest < ActiveSupport::TestCase +require "abstract_unit" +require "active_support/core_ext/object" +class DeepDupTest < ActiveSupport::TestCase def test_array_deep_dup array = [1, [2, 3]] dup = array.deep_dup dup[1][2] = 4 - assert_equal nil, array[1][2] + assert_nil array[1][2] assert_equal 4, dup[1][2] end def test_hash_deep_dup - hash = { :a => { :b => 'b' } } + hash = { a: { b: "b" } } dup = hash.deep_dup - dup[:a][:c] = 'c' - assert_equal nil, hash[:a][:c] - assert_equal 'c', dup[:a][:c] + dup[:a][:c] = "c" + assert_nil hash[:a][:c] + assert_equal "c", dup[:a][:c] end def test_array_deep_dup_with_hash_inside - array = [1, { :a => 2, :b => 3 } ] + array = [1, { a: 2, b: 3 } ] dup = array.deep_dup dup[1][:c] = 4 - assert_equal nil, array[1][:c] + assert_nil array[1][:c] assert_equal 4, dup[1][:c] end def test_hash_deep_dup_with_array_inside - hash = { :a => [1, 2] } + hash = { a: [1, 2] } dup = hash.deep_dup - dup[:a][2] = 'c' - assert_equal nil, hash[:a][2] - assert_equal 'c', dup[:a][2] + dup[:a][2] = "c" + assert_nil hash[:a][2] + assert_equal "c", dup[:a][2] end def test_deep_dup_initialize zero_hash = Hash.new 0 - hash = { :a => zero_hash } + hash = { a: zero_hash } dup = hash.deep_dup assert_equal 0, dup[:a][44] end @@ -46,14 +47,13 @@ class DeepDupTest < ActiveSupport::TestCase object = Object.new dup = object.deep_dup dup.instance_variable_set(:@a, 1) - assert !object.instance_variable_defined?(:@a) + assert_not object.instance_variable_defined?(:@a) assert dup.instance_variable_defined?(:@a) end def test_deep_dup_with_hash_class_key - hash = { Fixnum => 1 } + hash = { Integer => 1 } dup = hash.deep_dup assert_equal 1, dup.keys.length end - end diff --git a/activesupport/test/core_ext/object/duplicable_test.rb b/activesupport/test/core_ext/object/duplicable_test.rb index 042f5cfb34..5203434ae6 100644 --- a/activesupport/test/core_ext/object/duplicable_test.rb +++ b/activesupport/test/core_ext/object/duplicable_test.rb @@ -1,19 +1,25 @@ -require 'abstract_unit' -require 'bigdecimal' -require 'active_support/core_ext/object/duplicable' -require 'active_support/core_ext/numeric/time' +# frozen_string_literal: true + +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') + if RUBY_VERSION >= "2.5.0" + RAISE_DUP = [method(:puts)] + ALLOW_DUP = ["1", "symbol_from_string".to_sym, Object.new, /foo/, [], {}, Time.now, Class.new, Module.new, BigDecimal("4.56"), nil, false, true, 1, 2.3, Complex(1), Rational(1)] + else + RAISE_DUP = [method(:puts), Complex(1), Rational(1)] + ALLOW_DUP = ["1", "symbol_from_string".to_sym, Object.new, /foo/, [], {}, Time.now, Class.new, Module.new, BigDecimal("4.56"), nil, false, true, 1, 2.3] + end def test_duplicable rubinius_skip "* Method#dup is allowed at the moment on Rubinius\n" \ "* https://github.com/rubinius/rubinius/issues/3089" RAISE_DUP.each do |v| - assert !v.duplicable? + assert_not v.duplicable?, "#{ v.inspect } should not be duplicable" assert_raises(TypeError, v.class.name) { v.dup } end diff --git a/activesupport/test/core_ext/object/inclusion_test.rb b/activesupport/test/core_ext/object/inclusion_test.rb index 32d512eca3..8cbb4f848f 100644 --- a/activesupport/test/core_ext/object/inclusion_test.rb +++ b/activesupport/test/core_ext/object/inclusion_test.rb @@ -1,33 +1,35 @@ -require 'abstract_unit' -require 'active_support/core_ext/object/inclusion' +# frozen_string_literal: true + +require "abstract_unit" +require "active_support/core_ext/object/inclusion" class InTest < ActiveSupport::TestCase def test_in_array - assert 1.in?([1,2]) - assert !3.in?([1,2]) + assert 1.in?([1, 2]) + assert_not 3.in?([1, 2]) end def test_in_hash h = { "a" => 100, "b" => 200 } assert "a".in?(h) - assert !"z".in?(h) + assert_not "z".in?(h) end def test_in_string assert "lo".in?("hello") - assert !"ol".in?("hello") + assert_not "ol".in?("hello") assert ?h.in?("hello") end def test_in_range assert 25.in?(1..50) - assert !75.in?(1..50) + assert_not 75.in?(1..50) end def test_in_set - s = Set.new([1,2]) + s = Set.new([1, 2]) assert 1.in?(s) - assert !3.in?(s) + assert_not 3.in?(s) end module A @@ -43,14 +45,14 @@ class InTest < ActiveSupport::TestCase def test_in_module assert A.in?(B) assert A.in?(C) - assert !A.in?(A) - assert !A.in?(D) + assert_not A.in?(A) + assert_not A.in?(D) end - + def test_no_method_catching assert_raise(ArgumentError) { 1.in?(1) } end - + def test_presence_in assert_equal "stuff", "stuff".presence_in(%w( lots of stuff )) assert_nil "stuff".presence_in(%w( lots of crap )) diff --git a/activesupport/test/core_ext/object/instance_variables_test.rb b/activesupport/test/core_ext/object/instance_variables_test.rb index 9f4c5dc4f1..9052d209a3 100644 --- a/activesupport/test/core_ext/object/instance_variables_test.rb +++ b/activesupport/test/core_ext/object/instance_variables_test.rb @@ -1,11 +1,13 @@ -require 'abstract_unit' -require 'active_support/core_ext/object' +# frozen_string_literal: true + +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 +15,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".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..22659a4050 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,6 @@ -require 'abstract_unit' +# frozen_string_literal: true + +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 +11,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 +20,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 +29,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 02ab17fb64..4cdb6ed09f 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,8 @@ -require 'abstract_unit' -require 'json' -require 'json/encoding_test_cases' +# frozen_string_literal: true + +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 @@ -10,10 +12,10 @@ require 'json/encoding_test_cases' # The AS::JSON encoder requires the BigDecimal core_ext, which, unfortunately, # changes the BigDecimal#to_s output, and consequently the JSON gem output. So -# we need to require this unfront to ensure we don't get a false failure, but +# 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 +50,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..612156bd99 100644 --- a/activesupport/test/core_ext/object/to_param_test.rb +++ b/activesupport/test/core_ext/object/to_param_test.rb @@ -1,5 +1,7 @@ -require 'abstract_unit' -require 'active_support/core_ext/object/to_param' +# frozen_string_literal: true + +require "abstract_unit" +require "active_support/core_ext/object/to_param" class ToParamTest < ActiveSupport::TestCase class CustomString < String @@ -10,8 +12,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 +27,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..561dadbbcf 100644 --- a/activesupport/test/core_ext/object/to_query_test.rb +++ b/activesupport/test/core_ext/object/to_query_test.rb @@ -1,82 +1,98 @@ -require 'abstract_unit' -require 'active_support/ordered_hash' -require 'active_support/core_ext/object/to_query' -require 'active_support/core_ext/string/output_safety' +# frozen_string_literal: true + +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', - Hash[:account, {:person => {:id => 20}}, :person, {:id => 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', - :person => {:id => [10, 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', - :person => {:id => [20, 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', - { a: 1, b: { c: 3, d: {} } } - 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', - {a: [], b: 3} + assert_query_equal "a=1&b%5Bc%5D=3", + a: 1, b: { c: 3, d: {} } + 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", + 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 + def test_hash_not_sorted_lexicographically_for_nested_structure + params = { + "foo" => { + "contents" => [ + { "name" => "gorby", "id" => "123" }, + { "name" => "puff", "d" => "true" } + ] + } + } + expected = "foo[contents][][name]=gorby&foo[contents][][id]=123&foo[contents][][name]=puff&foo[contents][][d]=true" + + assert_equal expected, URI.decode_www_form_component(params.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 5ea0f0eca6..a838334034 100644 --- a/activesupport/test/core_ext/object/try_test.rb +++ b/activesupport/test/core_ext/object/try_test.rb @@ -1,5 +1,7 @@ -require 'abstract_unit' -require 'active_support/core_ext/object' +# frozen_string_literal: true + +require "abstract_unit" +require "active_support/core_ext/object" class ObjectTryTest < ActiveSupport::TestCase def setup @@ -8,26 +10,26 @@ class ObjectTryTest < ActiveSupport::TestCase def test_nonexisting_method method = :undefined_method - assert !@string.respond_to?(method) + assert_not_respond_to @string, method assert_nil @string.try(method) end def test_nonexisting_method_with_arguments method = :undefined_method - assert !@string.respond_to?(method) - assert_nil @string.try(method, 'llo', 'y') + assert_not_respond_to @string, method + assert_nil @string.try(method, "llo", "y") end def test_nonexisting_method_bang method = :undefined_method - assert !@string.respond_to?(method) + assert_not_respond_to @string, method assert_raise(NoMethodError) { @string.try!(method) } end def test_nonexisting_method_with_arguments_bang method = :undefined_method - assert !@string.respond_to?(method) - assert_raise(NoMethodError) { @string.try!(method, 'llo', 'y') } + assert_not_respond_to @string, method + assert_raise(NoMethodError) { @string.try!(method, "llo", "y") } end def test_valid_method @@ -35,11 +37,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 +50,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 @@ -76,9 +78,8 @@ class ObjectTryTest < ActiveSupport::TestCase def test_try_with_private_method_bang klass = Class.new do private - def private_method - 'private method' + "private method" end end @@ -88,9 +89,8 @@ class ObjectTryTest < ActiveSupport::TestCase def test_try_with_private_method klass = Class.new do private - def private_method - 'private method' + "private method" end end @@ -99,30 +99,29 @@ 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 - assert_equal 5, Decorator.new(@string).size + assert_equal 5, Decorator.new(@string).try(:size) end - def test_try_with_overriden_method_on_delegator - assert_equal 'overridden reverse', Decorator.new(@string).reverse + def test_try_with_overridden_method_on_delegator + assert_equal "overridden reverse", Decorator.new(@string).try(:reverse) end def test_try_with_private_method_on_delegator @@ -138,9 +137,8 @@ class ObjectTryTest < ActiveSupport::TestCase def test_try_with_private_method_on_delegator_target klass = Class.new do private - def private_method - 'private method' + "private method" end end @@ -150,9 +148,8 @@ class ObjectTryTest < ActiveSupport::TestCase def test_try_with_private_method_on_delegator_target_bang klass = Class.new do private - def private_method - 'private method' + "private method" end end |