diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-25 05:44:38 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-25 05:44:38 +0000 |
commit | 635d0822cdb3a9eb7612ea478601d17ebe76b74d (patch) | |
tree | 08029047a84a89d290ac70b5461ae5b620d8390a /spec/ruby | |
parent | 50a99a76791bcd09b15353d704226a9cb52fd2b9 (diff) | |
download | ruby-635d0822cdb3a9eb7612ea478601d17ebe76b74d.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/ruby')
-rw-r--r-- | spec/ruby/core/io/puts_spec.rb | 9 |
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 |