Skip to content

Commit 787c132

Browse files
yuguimame
authored andcommitted
The spec for interporation when Object#to_s did not return a String was confusing the default representation of an arbitrary object and Object#inspect.
1 parent e8c7795 commit 787c132

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

language/string_spec.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,13 @@
150150
"#{obj}".should == '42'
151151
end
152152

153-
it "interpolates the return value of Object#inspect, without ivars, if Object#to_s does not return a String instance" do
153+
it "interpolates an implementation depended representation of an object if the object does not return a String for #to_s and the representation of the object is not empty" do
154154
obj = mock('to_s')
155155
obj.stub!(:to_s).and_return(42)
156-
s = "#{obj}"[0..-2]
157156

158-
s.should == obj.inspect[0, s.size]
157+
s = nil
158+
lambda { s = "#{obj}" }.should_not raise_error
159+
s.should_not be_empty
159160
end
160161

161162
ruby_version_is '1.9' do

0 commit comments

Comments
 (0)