diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-28 09:21:58 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-28 09:21:58 +0000 |
commit | 7cf7ca79c71b361fe84d3f5243350f81f53ff3ff (patch) | |
tree | 7c7f6a770c6bc0e932aa2b0cdd3490501ae20856 /test | |
parent | 131eb749c6b44172501171e77151acff782c7a9b (diff) | |
download | ruby-7cf7ca79c71b361fe84d3f5243350f81f53ff3ff.tar.gz |
ostruct.rb: refine visibility failure message
* lib/ostruct.rb (method_missing): raise an exception with proper
visibility message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ostruct/test_ostruct.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb index b9bbaace55..32eb73a89d 100644 --- a/test/ostruct/test_ostruct.rb +++ b/test/ostruct/test_ostruct.rb @@ -192,4 +192,28 @@ class TC_OpenStruct < Test::Unit::TestCase os = assert_nothing_raised(ArgumentError, bug) {c.allocate} assert_instance_of(c, os) end + + def test_private_method + os = OpenStruct.new + class << os + private + def foo + end + end + assert_raise_with_message(NoMethodError, /private method/) do + os.foo true, true + end + end + + def test_protected_method + os = OpenStruct.new + class << os + protected + def foo + end + end + assert_raise_with_message(NoMethodError, /protected method/) do + os.foo true, true + end + end end |