Sha256: 99c200d60c035f0f83438597ffa5a0858505b85e111ef4f5db3ab16becb4fdea

Contents?: true

Size: 1.9 KB

Versions: 13

Compression:

Stored size: 1.9 KB

Contents

require 'spec_helper'

describe Heirloom do

  before do
    @logger_mock = mock 'logger'
    @logger_mock.stub :info => true, :debug => true
    @config_mock = mock 'config'
    @config_mock.stub :logger => @logger_mock
    @tempfile_stub = stub 'tempfile', :path => '/tmp/tempfile'
    Tempfile.stub :new => @tempfile_stub
    @writer = Heirloom::Writer.new :config => @config_mock
  end

  context "extract is set to true" do
    it "should extract the given archive object into the output directory" do
      File.should_receive(:open).with('/tmp/tempfile', 'w')
      Heirloom::Writer.any_instance.should_receive(:`).
                       with('tar xzf /tmp/tempfile -C /output')
      $?.stub :success? => true
      @writer.save_archive(:archive => 'archive_data', 
                           :output  => '/output',
                           :file    => 'id.tar.gz',
                           :extract => true).should be_true
    end

    it "should return false if the extract fails" do
      File.should_receive(:open).with('/tmp/tempfile', 'w')
      Heirloom::Writer.any_instance.should_receive(:`).
                       with('tar xzf /tmp/tempfile -C /output')
      $?.stub :success? => false
      @logger_mock.should_receive(:error).with "Error extracting archive."
      @writer.save_archive(:archive => 'archive_data', 
                           :output  => '/output',
                           :file    => 'id.tar.gz',
                           :extract => true).should be_false
    end
  end

  context "extract is set to false" do
    it "should save the given archive object into the output directory" do
      File.should_receive(:open).with('/output/id.tar.gz', 'w').
           and_return true
      @writer.save_archive :archive => 'archive_data', 
                           :output  => '/output',
                           :file    => 'id.tar.gz',
                           :extract => false
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
heirloom-0.7.4 spec/archive/writer_spec.rb
heirloom-0.7.3 spec/archive/writer_spec.rb
heirloom-0.7.3rc2 spec/archive/writer_spec.rb
heirloom-0.7.3rc1 spec/archive/writer_spec.rb
heirloom-0.7.2 spec/archive/writer_spec.rb
heirloom-0.7.2rc2 spec/archive/writer_spec.rb
heirloom-0.7.2rc1 spec/archive/writer_spec.rb
heirloom-0.7.1 spec/archive/writer_spec.rb
heirloom-0.7.0 spec/archive/writer_spec.rb
heirloom-0.7.0rc1 spec/archive/writer_spec.rb
heirloom-0.6.1 spec/archive/writer_spec.rb
heirloom-0.6.0rc1 spec/archive/writer_spec.rb
heirloom-0.5.0rc4 spec/archive/writer_spec.rb