test/xlsx_reader_test.rb in iostreams-0.15.0 vs test/xlsx_reader_test.rb in iostreams-0.16.0

- old
+ new

@@ -1,6 +1,7 @@ require_relative 'test_helper' +require 'csv' class XlsxReaderTest describe IOStreams::Xlsx::Reader do let :file_name do File.join(File.dirname(__FILE__), 'files', 'spreadsheet.xlsx') @@ -15,26 +16,22 @@ describe '.open' do describe 'with a file path' do it 'returns the contents of the file' do rows = [] - IOStreams::Xlsx::Reader.open(file_name) do |stream| - stream.each { |row| rows << row } - end - assert_equal xlsx_contents, rows + csv = IOStreams::Xlsx::Reader.open(file_name, &:read) + assert_equal xlsx_contents, CSV.parse(csv) end end describe 'with a file stream' do it 'returns the contents of the file' do - rows = [] - File.open(file_name) do |file| - IOStreams::Xlsx::Reader.open(file) do |stream| - stream.each { |row| rows << row } - end + csv = '' + File.open(file_name, 'rb') do |file| + csv = IOStreams::Xlsx::Reader.open(file, &:read) end - assert_equal xlsx_contents, rows + assert_equal xlsx_contents, CSV.parse(csv) end end end end end