Sha256: 97e6dcbaf3295c2d93a47c95507bbb377ed73de497bf0f5090788f4b96625c9d

Contents?: true

Size: 1.1 KB

Versions: 14

Compression:

Stored size: 1.1 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 '.open' do
      it 'file' do
        IOStreams::Bzip2::Writer.open(file_name) do |io|
          io.write(decompressed)
        end

        File.open(file_name, 'rb') do |file|
          io     = RBzip2.default_adapter::Decompressor.new(file)
          result = io.read
          temp_file.delete
          assert_equal decompressed, result
        end
      end

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

        io     = StringIO.new(io_string.string)
        rbzip2 = RBzip2.default_adapter::Decompressor.new(io)
        data   = rbzip2.read
        assert_equal decompressed, data
      end
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
iostreams-0.20.3 test/bzip2_writer_test.rb
iostreams-0.20.2 test/bzip2_writer_test.rb
iostreams-0.20.1 test/bzip2_writer_test.rb
iostreams-0.20.0 test/bzip2_writer_test.rb
iostreams-0.19.0 test/bzip2_writer_test.rb
iostreams-0.18.0 test/bzip2_writer_test.rb
iostreams-0.17.3 test/bzip2_writer_test.rb
iostreams-0.17.2 test/bzip2_writer_test.rb
iostreams-0.17.1 test/bzip2_writer_test.rb
iostreams-0.17.0 test/bzip2_writer_test.rb
iostreams-0.16.2 test/bzip2_writer_test.rb
iostreams-0.16.1 test/bzip2_writer_test.rb
iostreams-0.16.0 test/bzip2_writer_test.rb
iostreams-0.15.0 test/bzip2_writer_test.rb