Sha256: a34b82375fa4686686c84d00fb5ed7da66269d5c56a16efcb66de1604b5d4bca

Contents?: true

Size: 932 Bytes

Versions: 20

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

20 entries across 20 versions & 1 rubygems

Version Path
iostreams-1.10.3 test/xlsx_reader_test.rb
iostreams-1.10.2 test/xlsx_reader_test.rb
iostreams-1.10.1 test/xlsx_reader_test.rb
iostreams-1.10.0 test/xlsx_reader_test.rb
iostreams-1.9.0 test/xlsx_reader_test.rb
iostreams-1.8.0 test/xlsx_reader_test.rb
iostreams-1.7.0 test/xlsx_reader_test.rb
iostreams-1.6.2 test/xlsx_reader_test.rb
iostreams-1.6.1 test/xlsx_reader_test.rb
iostreams-1.6.0 test/xlsx_reader_test.rb
iostreams-1.5.1 test/xlsx_reader_test.rb
iostreams-1.5.0 test/xlsx_reader_test.rb
iostreams-1.4.0 test/xlsx_reader_test.rb
iostreams-1.3.3 test/xlsx_reader_test.rb
iostreams-1.3.2 test/xlsx_reader_test.rb
iostreams-1.3.1 test/xlsx_reader_test.rb
iostreams-1.3.0 test/xlsx_reader_test.rb
iostreams-1.2.1 test/xlsx_reader_test.rb
iostreams-1.2.0 test/xlsx_reader_test.rb
iostreams-1.1.1 test/xlsx_reader_test.rb