diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-11-12 16:19:33 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-11-13 09:52:52 -0800 |
commit | c0ebc2149380a59371553765053f55671c737533 (patch) | |
tree | d480a4fef04a5945151fce78f7909063711c9fee | |
parent | 2cb47c742fda56a50454f11eb2ccfbe5a9bd553f (diff) | |
download | rails-c0ebc2149380a59371553765053f55671c737533.tar.gz rails-c0ebc2149380a59371553765053f55671c737533.tar.bz2 rails-c0ebc2149380a59371553765053f55671c737533.zip |
Test that Array.wrap works with proxy objects and structs
-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 8198b9bd2c..f5f91ddd80 100644 --- a/activesupport/test/core_ext/array_ext_test.rb +++ b/activesupport/test/core_ext/array_ext_test.rb @@ -339,6 +339,11 @@ class ArrayWrapperTests < Test::Unit::TestCase end end + class Proxy + def initialize(target) @target = target end + def method_missing(*a) @target.send(*a) end + end + def test_array ary = %w(foo bar) assert_same ary, Array.wrap(ary) @@ -364,4 +369,19 @@ class ArrayWrapperTests < Test::Unit::TestCase def test_object_with_to_ary assert_equal ["foo", "bar"], Array.wrap(FakeCollection.new) end + + def test_proxy_object + p = Proxy.new(Object.new) + assert_equal [p], Array.wrap(p) + end + + def test_proxy_to_object_with_to_ary + p = Proxy.new(FakeCollection.new) + assert_equal [p], Array.wrap(p) + end + + def test_struct + o = Struct.new(:foo).new(123) + assert_equal [o], Array.wrap(o) + end end |