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 | a20715c8ed16616ab00674f134654f8be88e2033 (patch) | |
tree | 7c7f6a770c6bc0e932aa2b0cdd3490501ae20856 /test | |
parent | 50d6291d864a50a9653d65e8c8b1ab4b310b3e54 (diff) | |
download | ruby-a20715c8ed16616ab00674f134654f8be88e2033.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 |