Sha256: 9b39de871d7d94f5a69e9833e79d5e85f93cf25e0eb75365b6d4c788fee103a3

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

require_relative 'test_helper'

module Streams
  describe IOStreams::Xlsx::Reader do
    before do
      @xlsx_contents = [
        ['first column', 'second column', 'third column'],
        ['data 1', 'data 2', 'more data']
      ]
    end

    describe '.open' do
      let(:file_name) { File.join(File.dirname(__FILE__), 'files', 'spreadsheet.xlsx') }

      describe 'with a file path' do
        before do
          @file = File.open(file_name)
        end

        it 'returns the contents of the file' do
          rows = []
          IOStreams::Xlsx::Reader.open(@file) do |spreadsheet|
            spreadsheet.each { |row| rows << row }
          end
          assert_equal(@xlsx_contents, rows)
        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 |spreadsheet|
              spreadsheet.each { |row| rows << row }
            end
          end

          assert_equal(@xlsx_contents, rows)
        end
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
iostreams-0.14.0 test/xlsx_reader_test.rb
iostreams-0.13.0 test/xlsx_reader_test.rb
iostreams-0.12.1 test/xlsx_reader_test.rb
iostreams-0.12.0 test/xlsx_reader_test.rb
iostreams-0.11.0 test/xlsx_reader_test.rb
iostreams-0.10.1 test/xlsx_reader_test.rb
iostreams-0.10.0 test/xlsx_reader_test.rb
iostreams-0.9.1 test/xlsx_reader_test.rb
iostreams-0.9.0 test/xlsx_reader_test.rb