diff options
author | Benoit Daloze <eregontp@gmail.com> | 2023-02-27 21:02:44 +0100 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2023-02-27 21:02:44 +0100 |
commit | 18b4def471bb901d0baa4a1307185484cb05815f (patch) | |
tree | 779b24566144e9ee06c6f8de35bd2f7fd74ccdb4 /spec/ruby/core/struct/shared | |
parent | de60139053fa7c561858c5c5556d61c82f361dd9 (diff) |
Update to ruby/spec@e7dc804
Diffstat (limited to 'spec/ruby/core/struct/shared')
-rw-r--r-- | spec/ruby/core/struct/shared/inspect.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/ruby/core/struct/shared/inspect.rb b/spec/ruby/core/struct/shared/inspect.rb index 90594a5452..e65a4fb45d 100644 --- a/spec/ruby/core/struct/shared/inspect.rb +++ b/spec/ruby/core/struct/shared/inspect.rb @@ -1,5 +1,28 @@ describe :struct_inspect, shared: true do + it "returns a string representation showing members and values" do + car = StructClasses::Car.new('Ford', 'Ranger') + car.send(@method).should == '#<struct StructClasses::Car make="Ford", model="Ranger", year=nil>' + end + it "returns a string representation without the class name for anonymous structs" do Struct.new(:a).new("").send(@method).should == '#<struct a="">' end + + it "returns a string representation without the class name for structs nested in anonymous classes" do + c = Class.new + c.class_eval <<~DOC + class Foo < Struct.new(:a); end + DOC + + c::Foo.new("").send(@method).should == '#<struct a="">' + end + + it "returns a string representation without the class name for structs nested in anonymous modules" do + m = Module.new + m.module_eval <<~DOC + class Foo < Struct.new(:a); end + DOC + + m::Foo.new("").send(@method).should == '#<struct a="">' + end end |