test/helper.rb in tracksperanto-2.8.5 vs test/helper.rb in tracksperanto-2.8.6
- old
+ new
@@ -90,25 +90,26 @@
yield(x) if block_given?
export_parabolics_with(x)
end
end
+ def assert_same_buffer(ref_buffer, actual_buffer, message = "The line should be identical")
+ [ref_buffer, actual_buffer].each{|io| io.rewind }
+ at_line = 0
+ until ref_buffer.eof? && actual_buffer.eof?
+ at_line += 1
+ reference_line, output_line = ref_buffer.readline, actual_buffer.readline
+ assert_equal reference_line, output_line, "Line #{at_line} - #{message}"
+ end
+ end
+
def ensure_same_output(exporter_klass, reference_path, message = "The line should be identical")
-
io = StringIO.new
x = exporter_klass.new(io)
yield(x) if block_given?
export_parabolics_with(x)
- io.rewind
- File.open(reference_path, "r") do | f |
- at_line = 0
- until f.eof? || io.eof?
- at_line += 1
- reference_line, output_line = f.readline, io.readline
- assert_equal reference_line, output_line, "Line #{at_line} - #{message}"
- end
- end
+ assert_same_buffer(File.open(reference_path, "r"), io, message)
end
def export_parabolics_with(exporter)
exporter.start_export(1920, 1080)
[FIRST_TRACK, SECOND_TRACK, SINGLE_FRAME_TRACK].each do | t |
\ No newline at end of file