Sha256: f74a8d9663ba59a16151bfe9d8ec40dc273375c9621768d7f0ae243891649a8f

Contents?: true

Size: 931 Bytes

Versions: 4

Compression:

Stored size: 931 Bytes

Contents

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')
    end

    let :xlsx_contents do
      [
        ['first column', 'second column', 'third column'],
        ['data 1', 'data 2', 'more data']
      ]
    end

    describe '.open' do
      describe 'with a file path' do
        it 'returns the contents of the file' do
          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
          csv = ''
          File.open(file_name, 'rb') do |file|
            csv = IOStreams::Xlsx::Reader.open(file, &:read)
          end

          assert_equal xlsx_contents, CSV.parse(csv)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
iostreams-0.20.3 test/xlsx_reader_test.rb
iostreams-0.20.2 test/xlsx_reader_test.rb
iostreams-0.20.1 test/xlsx_reader_test.rb
iostreams-0.20.0 test/xlsx_reader_test.rb