Skip to content

Commit 161be68

Browse files
committed
Move a Struct#inspect spec to the shared behavior file so it can be run with Struct#to_s as well.
1 parent f69fede commit 161be68

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

spec/ruby/core/struct/inspect_spec.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,5 @@
33
require_relative 'shared/inspect'
44

55
describe "Struct#inspect" do
6-
it "returns a string representation showing members and values" do
7-
car = StructClasses::Car.new('Ford', 'Ranger')
8-
car.inspect.should == '#<struct StructClasses::Car make="Ford", model="Ranger", year=nil>'
9-
end
10-
116
it_behaves_like :struct_inspect, :inspect
127
end

spec/ruby/core/struct/shared/inspect.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
describe :struct_inspect, shared: true do
2+
it "returns a string representation showing members and values" do
3+
car = StructClasses::Car.new('Ford', 'Ranger')
4+
car.send(@method).should == '#<struct StructClasses::Car make="Ford", model="Ranger", year=nil>'
5+
end
6+
27
it "returns a string representation without the class name for anonymous structs" do
38
Struct.new(:a).new("").send(@method).should == '#<struct a="">'
49
end

0 commit comments

Comments
 (0)