Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2129 from ashmoran/issue_2113_stringio_puts_nil

Fix issue 2113 StringIO puts printing nil
  • Loading branch information...
commit 2ddcb4db178c67faff636f73f4af7417cc7c0418 2 parents 0c1a67f + ff18a46
@brixen brixen authored
View
2  lib/19/stringio.rb
@@ -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
2  lib/20/stringio.rb
@@ -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
14 spec/ruby/library/stringio/puts_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.