From 635d0822cdb3a9eb7612ea478601d17ebe76b74d Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 25 Oct 2017 05:44:38 +0000 Subject: 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 --- spec/ruby/core/io/puts_spec.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'spec') 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("#") - @io.should_receive(:write).with("#") - @io.should_receive(:write).with("\n") @io.puts(object).should == nil + ScratchPad.recorded.should == "#\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 -- cgit v1.2.3