From caa31652ee976e3a97093eb8b9752a8272cf1587 Mon Sep 17 00:00:00 2001 From: Eneroth Date: Wed, 23 Aug 2023 17:08:26 +0200 Subject: [PATCH] Fix #210 Recreate Ruby's line breaks in Puts Without TestUp `puts [1,2,3]` outputs as: ``` 1 2 3 ``` Without TestUp it outputs as `[1, 2, 3]`. This fix restores the default Ruby behavior to puts for Arrays. --- src/testup/console.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/testup/console.rb b/src/testup/console.rb index 548d768..522a349 100644 --- a/src/testup/console.rb +++ b/src/testup/console.rb @@ -54,11 +54,15 @@ def puts(*args) if args.empty? write $/ else - for arg in args - line = arg.to_s - write(line) - if line.empty? || !line.end_with?($/) - write($/) + for arg in args # Why not 'args.each do |arg|' ? + if arg.is_a?(Array) + arg.each { |e| puts(e) } + else + line = arg.to_s + write(line) + if line.empty? || !line.end_with?($/) + write($/) + end end end end