diff --git a/lib/sof/array.rb b/lib/sof/array.rb index ff7f73d2..dba030d5 100644 --- a/lib/sof/array.rb +++ b/lib/sof/array.rb @@ -1,7 +1,7 @@ Array.class_eval do def to_sof(io , members , level) - each do |object| - io.write(" " * level) + each_with_index do |object , i| + io.write(" " * level) unless i == 0 io.write("-") members.output(io , object) io.write("\n") diff --git a/test/sof.rb b/test/sof.rb index fd14b62e..eb931aec 100644 --- a/test/sof.rb +++ b/test/sof.rb @@ -28,5 +28,9 @@ class BasicSof < MiniTest::Test out = Sof::Writer.write([true, 1234 , ObjectWithAttributes.new]) assert_equal "-true\n-1234\n-ObjectWithAttributes(name: 'some object' ,number: 1234)\n\n" , out end + def test_array_with_array + out = Sof::Writer.write([true, 1234 , [true , 12 ]]) + assert_equal "-true\n-1234\n--true\n -12\n\n" , out + end end \ No newline at end of file