Skip to content

Commit

Permalink
Fixes error for puts <number>
Browse files Browse the repository at this point in the history
error: String can't be coerced into Fixnum (TypeError)
  • Loading branch information
mattscilipoti committed May 17, 2011
1 parent ed2b3e1 commit 95f8488
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/kidsruby/stdio.rb
Expand Up @@ -9,9 +9,9 @@ def write(data)
t = data.gsub(/\n/,"<br/>")
@iface.call("append", t)
end

def puts(data)
write(data + "\n")
write(data.to_s + "\n")
end
end

Expand All @@ -30,4 +30,4 @@ def puts(data)
$stdout = StdOut.new

$stderr.sync = true
$stderr = StdErr.new
$stderr = StdErr.new
13 changes: 13 additions & 0 deletions spec/models/std_io_spec.rb
@@ -0,0 +1,13 @@
require_relative "../spec_helper"
require_relative "../../lib/kidsruby"

describe StdOut do
describe ".puts" do
it "should delegate the coerced, new-lined data to .write" do
stdout_ut = StdOut.new
stdout_ut.expects(:write).with("123\n")
stdout_ut.puts(123)
end
end
end

0 comments on commit 95f8488

Please sign in to comment.