From c0ebc2149380a59371553765053f55671c737533 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 12 Nov 2009 16:19:33 -0800 Subject: Test that Array.wrap works with proxy objects and structs --- activesupport/test/core_ext/array_ext_test.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 -- cgit v1.2.3