Sha256: 39ac5a0a49c0d13aa971896db5c1ac0747b0bd8019f0fba7ce15bec293a0e6a8

Contents?: true

Size: 951 Bytes

Versions: 9

Compression:

Stored size: 951 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
          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
          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

9 entries across 9 versions & 1 rubygems

Version Path
iostreams-0.19.0 test/xlsx_reader_test.rb
iostreams-0.18.0 test/xlsx_reader_test.rb
iostreams-0.17.3 test/xlsx_reader_test.rb
iostreams-0.17.2 test/xlsx_reader_test.rb
iostreams-0.17.1 test/xlsx_reader_test.rb
iostreams-0.17.0 test/xlsx_reader_test.rb
iostreams-0.16.2 test/xlsx_reader_test.rb
iostreams-0.16.1 test/xlsx_reader_test.rb
iostreams-0.16.0 test/xlsx_reader_test.rb