Permalink
Browse files

Merge pull request #2129 from ashmoran/issue_2113_stringio_puts_nil

Fix issue 2113 StringIO puts printing nil
  • Loading branch information...
2 parents 0c1a67f + ff18a46 commit 2ddcb4db178c67faff636f73f4af7417cc7c0418 @brixen brixen committed Jan 21, 2013
Showing with 16 additions and 2 deletions.
  1. +1 −1 lib/19/stringio.rb
  2. +1 −1 lib/20/stringio.rb
  3. +14 −0 spec/ruby/library/stringio/puts_spec.rb
View
@@ -357,7 +357,7 @@ def puts(*args)
else
args.each do |arg|
if arg.nil?
- line = "nil"
+ line = ""
elsif Thread.guarding? arg
line = "[...]"
else
View
@@ -357,7 +357,7 @@ def puts(*args)
else
args.each do |arg|
if arg.nil?
- line = "nil"
+ line = ""
elsif Thread.guarding? arg
line = "[...]"
else
@@ -91,6 +91,20 @@
@io.puts ''
@io.string.should == "\n"
end
+
+ ruby_version_is ""..."1.9" do
+ it "prints a newline when passed nil" do
+ @io.puts nil
+ @io.string.should == "nil\n"
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "prints a newline when passed nil" do
+ @io.puts nil
+ @io.string.should == "\n"
+ end
+ end
end
describe "StringIO#puts when passed no arguments" do

0 comments on commit 2ddcb4d

Please sign in to comment.