From 12f8887865ce429f4f3bbddcc704f38397f7d8b7 Mon Sep 17 00:00:00 2001 From: Matt Scilipoti Date: Tue, 17 May 2011 10:56:06 -0400 Subject: [PATCH] Fixes error for `StdErr.puts ` error: String can't be coerced into Fixnum (TypeError) --- lib/kidsruby/stdio.rb | 2 +- spec/models/std_io_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/kidsruby/stdio.rb b/lib/kidsruby/stdio.rb index d4198c5..69666f9 100644 --- a/lib/kidsruby/stdio.rb +++ b/lib/kidsruby/stdio.rb @@ -22,7 +22,7 @@ def write(data) end def puts(data) - write(data + "\n") + write(data.to_s + "\n") end end diff --git a/spec/models/std_io_spec.rb b/spec/models/std_io_spec.rb index c23556c..b2cda2c 100644 --- a/spec/models/std_io_spec.rb +++ b/spec/models/std_io_spec.rb @@ -11,3 +11,12 @@ end end +describe StdErr do + describe ".puts" do + it "should delegate the coerced, newlined data to .write" do + stderr_ut = StdErr.new + stderr_ut.expects(:write).with("234\n") + stderr_ut.puts(234) + end + end +end