diff options
Diffstat (limited to 'activesupport/test/core_ext/array_ext_test.rb')
-rw-r--r-- | activesupport/test/core_ext/array_ext_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb index 54376deee5..009a254c64 100644 --- a/activesupport/test/core_ext/array_ext_test.rb +++ b/activesupport/test/core_ext/array_ext_test.rb @@ -398,6 +398,18 @@ class ArrayWrapperTests < Test::Unit::TestCase def method_missing(*a) @target.send(*a) end end + class DoubtfulToAry + def to_ary + :not_an_array + end + end + + class NilToAry + def to_ary + nil + end + end + def test_array ary = %w(foo bar) assert_same ary, Array.wrap(ary) @@ -438,4 +450,12 @@ class ArrayWrapperTests < Test::Unit::TestCase o = Struct.new(:foo).new(123) assert_equal [o], Array.wrap(o) end + + def test_wrap_returns_nil_if_to_ary_returns_nil + assert_nil Array.wrap(NilToAry.new) + end + + def test_wrap_does_not_complain_if_to_ary_does_not_return_an_array + assert_equal DoubtfulToAry.new.to_ary, Array.wrap(DoubtfulToAry.new) + end end |