Sha256: 5eaa4af0b9c54a8c1a65a4ee9002fa85628795c89a238a83542f00f03c3abf30

Contents?: true

Size: 1.1 KB

Versions: 9

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 '.file' do
      it 'file' do
        IOStreams::Bzip2::Writer.file(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.stream(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

9 entries across 9 versions & 1 rubygems

Version Path
iostreams-1.1.0 test/bzip2_writer_test.rb
iostreams-1.0.0 test/bzip2_writer_test.rb
iostreams-1.0.0.beta7 test/bzip2_writer_test.rb
iostreams-1.0.0.beta6 test/bzip2_writer_test.rb
iostreams-1.0.0.beta5 test/bzip2_writer_test.rb
iostreams-1.0.0.beta4 test/bzip2_writer_test.rb
iostreams-1.0.0.beta3 test/bzip2_writer_test.rb
iostreams-1.0.0.beta2 test/bzip2_writer_test.rb
iostreams-1.0.0.beta test/bzip2_writer_test.rb