From e44e356b53828d6468114b30e5c169296896f9b1 Mon Sep 17 00:00:00 2001 From: marcandre Date: Sun, 28 Oct 2012 21:20:10 +0000 Subject: * lib/ostruct.rb: Add [] and []=, base on a patch by Thomas Sawyer [ruby-core:42779] [Feature #6056] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ostruct/test_ostruct.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'test/ostruct/test_ostruct.rb') diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb index 491f950838..d82bab9784 100644 --- a/test/ostruct/test_ostruct.rb +++ b/test/ostruct/test_ostruct.rb @@ -70,14 +70,19 @@ class TC_OpenStruct < Test::Unit::TestCase assert_equal(a, 'a') end - def test_method_missing_handles_square_bracket_equals - o = OpenStruct.new - assert_raise(NoMethodError) { o[:foo] = :bar } + def test_setter + os = OpenStruct.new + os[:foo] = :bar + assert_equal :bar, os.foo + os['foo'] = :baz + assert_equal :baz, os.foo end - def test_method_missing_handles_square_brackets - o = OpenStruct.new - assert_raise(NoMethodError) { o[:foo] } + def test_getter + os = OpenStruct.new + os.foo = :bar + assert_equal :bar, os[:foo] + assert_equal :bar, os['foo'] end def test_to_h -- cgit v1.2.3