diff options
author | Benoit Daloze <[email protected]> | 2024-02-05 16:29:57 +0100 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2024-02-05 16:29:57 +0100 |
commit | 40642cd3bc581d3bb402ea5e8e61cdfb868b4f68 (patch) | |
tree | 077cc3ac94f880ce3c8c98322331c01cb1cc9cb8 /spec/ruby/core/exception | |
parent | abe07d4bf5f2f848b22e511a647a85c878066adb (diff) |
Update to ruby/spec@3fc4444
Diffstat (limited to 'spec/ruby/core/exception')
-rw-r--r-- | spec/ruby/core/exception/frozen_error_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/ruby/core/exception/frozen_error_spec.rb b/spec/ruby/core/exception/frozen_error_spec.rb index 2efdc239d8..979ec2ff98 100644 --- a/spec/ruby/core/exception/frozen_error_spec.rb +++ b/spec/ruby/core/exception/frozen_error_spec.rb @@ -20,3 +20,19 @@ describe "FrozenError#receiver" do end end end + +describe "Modifying a frozen object" do + context "#inspect is redefined and modifies the object" do + it "returns ... instead of String representation of object" do + object = Object.new + def object.inspect; @a = 1 end + def object.modify; @a = 2 end + + object.freeze + + # CRuby's message contains multiple whitespaces before '...'. + # So handle both multiple and single whitespace. + -> { object.modify }.should raise_error(FrozenError, /can't modify frozen .*?: \s*.../) + end + end +end |