Sha256: fa9f0681eb8304518c9a1ee8d93fcfcd7e570d145a18d4a1591db744974c9538

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require_relative 'test_helper'

module Streams
  describe IOStreams::Xlsx::Reader do
    XLSX_CONTENTS = [
      "first column,second column,third column",
      "data 1,data 2,more data",
    ]

    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_line { |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_line { |row| rows << row }
            end
          end

          assert_equal(XLSX_CONTENTS, rows)
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iostreams-0.8.2 test/xlsx_reader_test.rb