Sha256: 9ff239db84d58c88a818c19e86a858da179fbdaf31664feb1bb3e53a34dc5c66

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

describe Heirloom::Directory do

  describe 'build_artifact_from_directory' do
    before do
      @config_mock = double 'config'
      @logger_stub = stub :debug => 'true', :info => 'true', :warn => 'true'
      @config_mock.stub(:logger).and_return(@logger_stub)
      @directory = Heirloom::Directory.new :config  => @config_mock,
                                           :exclude => ['.', '..', 'dont_pack_me'],
                                           :path    => '/target/dir'
      @directory.stub :random_archive => '/tmp/dir/file.tar.gz'
      output_mock  = double 'output mock'
      Dir.stub :tmpdir => '/tmp/dir'
      Dir.should_receive(:entries).with('/target/dir').
                                   exactly(2).times.
                                   and_return(['pack_me', '.hidden', 'dont_pack_me'])
      Heirloom::Directory.any_instance.should_receive(:`).
                          with("tar czf /tmp/dir/file.tar.gz pack_me .hidden").
                          and_return output_mock
    end

    it "should build an archive from the latest commit in path" do
      $?.should_receive(:success?).and_return true
      @directory.build_artifact_from_directory.should be_true
    end

    context 'when unable to create the tar' do
      before { $?.stub(:success?).and_return(false) }

      it "should build return false" do
        @directory.build_artifact_from_directory.should be_false
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heirloom-0.5.0rc2 spec/directory/directory_spec.rb