summaryrefslogtreecommitdiff
path: root/test/ostruct
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-27 15:59:02 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-27 15:59:02 +0000
commita50bdcd6dfe4e7eec48bee5b40aebaaa5513e053 (patch)
tree5a9aaa1ecc7939122f0a83217e068271fe715ee9 /test/ostruct
parent40e7d793917c1c00fed590814d401ffd1d341991 (diff)
* lib/ostruct.rb (method_missing): Handle [] and []= correctly.
Based on a patch by Caius Durling, bug #4179 [ruby-core:33792] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ostruct')
-rw-r--r--test/ostruct/test_ostruct.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb
index 5c83bfd..db8e741 100644
--- a/test/ostruct/test_ostruct.rb
+++ b/test/ostruct/test_ostruct.rb
@@ -61,4 +61,15 @@ class TC_OpenStruct < Test::Unit::TestCase
assert_not_respond_to(o, :a, bug)
assert_not_respond_to(o, :a=, bug)
end
+
+ def test_method_missing_handles_square_bracket_equals
+ o = OpenStruct.new
+ assert_raise(NoMethodError) { o[:foo] = :bar }
+ end
+
+ def test_method_missing_handles_square_brackets
+ o = OpenStruct.new
+ assert_raise(NoMethodError) { o[:foo] }
+ end
+
end