diff --git a/gem/terminalwire-server/lib/terminalwire/server/resource.rb b/gem/terminalwire-server/lib/terminalwire/server/resource.rb index 51d262f..4679e6c 100644 --- a/gem/terminalwire-server/lib/terminalwire/server/resource.rb +++ b/gem/terminalwire-server/lib/terminalwire/server/resource.rb @@ -36,8 +36,8 @@ def read(name) end class STDOUT < Base - def puts(data) - command("print_line", data: data) + def puts(data = nil) + command("print_line", data: data.to_s) end def print(data) diff --git a/spec/integration/resources/stdout_spec.rb b/spec/integration/resources/stdout_spec.rb index 2b222f5..c4ab027 100644 --- a/spec/integration/resources/stdout_spec.rb +++ b/spec/integration/resources/stdout_spec.rb @@ -18,6 +18,14 @@ it 'prints line with newline to stdout through client' do expect { server_stdout.puts("Hello line") }.to output("Hello line\n").to_stdout end + + it 'prints a blank line when called with no arguments' do + expect { server_stdout.puts }.to output("\n").to_stdout + end + + it 'prints a blank line when called with nil' do + expect { server_stdout.puts(nil) }.to output("\n").to_stdout + end end describe '#flush' do