Sha256: ec315e3b3721d71f48fb31b420af0dee72bde56666d18eac5bad21938743d9dd

Contents?: true

Size: 1.16 KB

Versions: 12

Compression:

Stored size: 1.16 KB

Contents

require_relative "test_helper"

class Bzip2WriterTest < Minitest::Test
  describe IOStreams::Bzip2::Writer do
    let :temp_file do
      Tempfile.new("iostreams")
    end

    let :file_name do
      temp_file.path
    end

    let :decompressed do
      File.read(File.join(File.dirname(__FILE__), "files", "text.txt"))
    end

    after do
      temp_file.delete
    end

    describe ".file" do
      it "file" do
        IOStreams::Bzip2::Writer.file(file_name) do |io|
          io.write(decompressed)
          io.write(decompressed)
        end

        File.open(file_name, "rb") do |file|
          io     = ::Bzip2::FFI::Reader.new(file)
          result = io.read
          temp_file.delete
          assert_equal decompressed + decompressed, result
        end
      end

      it "stream" do
        io_string = StringIO.new("".b)
        IOStreams::Bzip2::Writer.stream(io_string) do |io|
          io.write(decompressed)
          io.write(decompressed)
        end

        io     = StringIO.new(io_string.string)
        rbzip2 = ::Bzip2::FFI::Reader.new(io)
        data   = rbzip2.read
        assert_equal decompressed + decompressed, data
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
iostreams-1.10.2 test/bzip2_writer_test.rb
iostreams-1.10.1 test/bzip2_writer_test.rb
iostreams-1.10.0 test/bzip2_writer_test.rb
iostreams-1.9.0 test/bzip2_writer_test.rb
iostreams-1.8.0 test/bzip2_writer_test.rb
iostreams-1.7.0 test/bzip2_writer_test.rb
iostreams-1.6.2 test/bzip2_writer_test.rb
iostreams-1.6.1 test/bzip2_writer_test.rb
iostreams-1.6.0 test/bzip2_writer_test.rb
iostreams-1.5.1 test/bzip2_writer_test.rb
iostreams-1.5.0 test/bzip2_writer_test.rb
iostreams-1.4.0 test/bzip2_writer_test.rb