Sha256: 53c0b29663d1906cbf943fbdab3b1d3fa4f8a597397871833cc65d92acd3e17e

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'
require 'albacore/unzip'

describe Unzip, "when providing configuration" do
  let :uz do
    Albacore.configure do |config|
      config.unzip.file = "configured"
    end
    uz = Unzip.new
  end

  it "should use the configured values" do
    uz.file.should == "configured"
  end

  it "should not 'force' by default" do
    uz.instance_variable_get(:@force).should be_nil
  end
  
  it "should enable 'force' by calling the force() method" do
    uz.force
    uz.instance_variable_get(:@force).should be_true
  end
end

describe Unzip, "when executing the task" do
  let :uz do
    zipped_file = mock('foo.txt')
    zipped_file.stub(:name).and_return('foo.txt')

    zip_file = mock('foo.zip')
    zip_file.stub(:each).and_yield(zipped_file)
    zip_file.stub(:extract)

    Zip::File.stub!(:open).and_yield(zip_file)
    FileUtils.stub(:mkdir_p)
    File.stub!(:file?).and_return(true)

    uz = Unzip.new
    uz.file = 'foo.zip'
    uz.destination = '/tmp'
    uz
  end

  it "should delete the destinationfile if forced" do
    File.should_receive(:delete).with('/tmp/foo.txt')

    uz.force
    uz.execute
  end

  it "should keep the destination file if not forced" do
    File.should_not_receive(:delete)

    uz.execute
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
albacore-1.0.0.rc.2 spec/unzip_spec.rb