diff --git a/lib/ostruct.rb b/lib/ostruct.rb index df09cc953f..6b60bdf3fe 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -152,7 +152,7 @@ class OpenStruct begin @modifiable = true rescue - raise TypeError, "can't modify frozen #{self.class}", caller(3) + raise RuntimeError, "can't modify frozen #{self.class}", caller(3) end @table end diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb index d82bab9784..a472509b88 100644 --- a/test/ostruct/test_ostruct.rb +++ b/test/ostruct/test_ostruct.rb @@ -46,14 +46,14 @@ class TC_OpenStruct < Test::Unit::TestCase o = OpenStruct.new o.a = 'a' o.freeze - assert_raise(TypeError) {o.b = 'b'} + assert_raise(RuntimeError) {o.b = 'b'} assert_not_respond_to(o, :b) - assert_raise(TypeError) {o.a = 'z'} + assert_raise(RuntimeError) {o.a = 'z'} assert_equal('a', o.a) o = OpenStruct.new :a => 42 def o.frozen?; nil end o.freeze - assert_raise(TypeError, '[ruby-core:22559]') {o.a = 1764} + assert_raise(RuntimeError, '[ruby-core:22559]') {o.a = 1764} end def test_delete_field