Sha256: 4eae7e4c6fb5358a8716560c83e49a5f63715d86cbd81c5369def5f7ba1f4b19

Contents?: true

Size: 1.51 KB

Versions: 17

Compression:

Stored size: 1.51 KB

Contents

require File.join(File.dirname(__FILE__),'../spec_helper')

# To use this shared example group define an instance variable
# <tt>@extension</tt> in your tests:
#
#   before do
#     # Notice that there is NO leading '.'
#     @extension = 'gz'
#   end
#
#   it_should_behave_like "a compressed file"
#
# The <tt>@extension</tt> should correspond to an IMW module with a
# registered handler.

share_examples_for "a compressed file" do

  before do
    @root = File.join(IMWTest::TMP_DIR, 'a_compressed_file_shared_example_group')
    FileUtils.mkdir_p(@root)
    FileUtils.cd(@root)
    IMWTest::Random.file("compressed_file.#{@extension}") # define @extension in another spec
    @compressed_file = IMW::Resource.new("compressed_file.#{@extension}")
  end

  it "should know that it is compressed" do
    @compressed_file.is_compressed?.should   be_true
    @compressed_file.is_compressible?.should be_false
  end

  it "can decompress the file in place" do
    uncompressed_file = @compressed_file.decompress!
    @compressed_file.exist?.should  be_false
    uncompressed_file.exist?.should be_true
    uncompressed_file.is_compressed?.should be_false
    uncompressed_file.is_compressible?.should be_true
  end

  it "can decompress the file without deleting the original file" do
    uncompressed_file = @compressed_file.decompress
    @compressed_file.exist?.should  be_true
    uncompressed_file.exist?.should be_true
    uncompressed_file.is_compressed?.should be_false
    uncompressed_file.is_compressible?.should be_true
  end
  
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
imw-0.2.18 spec/imw/compressed_files_spec.rb
imw-0.2.17 spec/imw/compressed_files_spec.rb
imw-0.2.16 spec/imw/compressed_files_spec.rb
imw-0.2.15 spec/imw/compressed_files_spec.rb
imw-0.2.14 spec/imw/compressed_files_spec.rb
imw-0.2.13 spec/imw/compressed_files_spec.rb
imw-0.2.12 spec/imw/compressed_files_spec.rb
imw-0.2.11 spec/imw/compressed_files_spec.rb
imw-0.2.10 spec/imw/compressed_files_spec.rb
imw-0.2.9 spec/imw/compressed_files_spec.rb
imw-0.2.8 spec/imw/compressed_files_spec.rb
imw-0.2.7 spec/imw/compressed_files_spec.rb
imw-0.2.6 spec/imw/compressed_files_spec.rb
imw-0.2.5 spec/imw/compressed_files_spec.rb
imw-0.2.4 spec/imw/compressed_files_spec.rb
imw-0.2.3 spec/imw/compressed_files_spec.rb
imw-0.2.2 spec/imw/compressed_files_spec.rb