aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-25 05:44:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-25 05:44:38 +0000
commit908341aabb97dcbd43364c3f27a1b37b5dc140dc (patch)
tree08029047a84a89d290ac70b5461ae5b620d8390a /spec
parentc22d62485fd20fbd4f79b026b7a03314caa0f81c (diff)
downloadruby-908341aabb97dcbd43364c3f27a1b37b5dc140dc.tar.gz
io.c: write a newline together
* io.c (rb_io_puts): write a newline together at once for each argument. based on the patch by rohitpaulk (Rohit Kuruvilla) at [ruby-core:83508]. [Feature #14042] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/core/io/puts_spec.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/spec/ruby/core/io/puts_spec.rb b/spec/ruby/core/io/puts_spec.rb
index 8f2f4f2c81..51240eed73 100644
--- a/spec/ruby/core/io/puts_spec.rb
+++ b/spec/ruby/core/io/puts_spec.rb
@@ -43,18 +43,16 @@ describe "IO#puts" do
object.should_receive(:method_missing).with(:to_ary)
object.should_receive(:to_s).and_return("#<Object:0x...>")
- @io.should_receive(:write).with("#<Object:0x...>")
- @io.should_receive(:write).with("\n")
@io.puts(object).should == nil
+ ScratchPad.recorded.should == "#<Object:0x...>\n"
end
it "calls :to_ary before writing non-string objects" do
object = mock('hola')
object.should_receive(:to_ary).and_return(["hola"])
- @io.should_receive(:write).with("hola")
- @io.should_receive(:write).with("\n")
@io.puts(object).should == nil
+ ScratchPad.recorded.should == "hola\n"
end
it "calls :to_s before writing non-string objects that don't respond to :to_ary" do
@@ -69,9 +67,8 @@ describe "IO#puts" do
object = mock('hola')
object.should_receive(:to_s).and_return(false)
- @io.should_receive(:write).with(object.inspect.split(" ")[0] + ">")
- @io.should_receive(:write).with("\n")
@io.puts(object).should == nil
+ ScratchPad.recorded.should == object.inspect.split(" ")[0] + ">\n"
end
it "writes each arg if given several" do