Sha256: 825fa4299e5f82b90619347d55df5937b6ecf536c0d078a008d559922a6dcfa8

Contents?: true

Size: 932 Bytes

Versions: 9

Compression:

Stored size: 932 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 '.file' do
      describe 'with a file path' do
        it 'returns the contents of the file' do
          csv = IOStreams::Xlsx::Reader.file(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.stream(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-1.1.0 test/xlsx_reader_test.rb
iostreams-1.0.0 test/xlsx_reader_test.rb
iostreams-1.0.0.beta7 test/xlsx_reader_test.rb
iostreams-1.0.0.beta6 test/xlsx_reader_test.rb
iostreams-1.0.0.beta5 test/xlsx_reader_test.rb
iostreams-1.0.0.beta4 test/xlsx_reader_test.rb
iostreams-1.0.0.beta3 test/xlsx_reader_test.rb
iostreams-1.0.0.beta2 test/xlsx_reader_test.rb
iostreams-1.0.0.beta test/xlsx_reader_test.rb