Sha256: 83ed96865568af3afbfff50d671c603b51551101f79e6f76c09fc7538cf29f78

Contents?: true

Size: 1.1 KB

Versions: 14

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe Berkshelf::Packager do
  let(:target) { tmp_path.join("cookbooks.tar.gz").to_s }
  subject { described_class.new(target) }

  its(:out_file) { should eql(target) }

  describe "#run" do
    let(:cookbooks) { fixtures_path.join("cookbooks") }

    it "writes a tar to the #out_file" do
      subject.run(cookbooks)
      expect(File.exist?(subject.out_file)).to be_true
    end
  end

  describe "#validate!" do
    let(:out_dir) { File.dirname(target) }

    context "when the out_file's directory is not writable" do
      before { File.stub(:directory?).with(out_dir).and_return(false) }

      it "raises an error" do
        expect { subject.validate! }.to raise_error(Berkshelf::PackageError,
          "Path is not a directory: #{out_dir}")
      end
    end

    context "when the out_file's directory is not a directory" do
      before { File.stub(:writable?).with(out_dir).and_return(false) }

      it "raises an error" do
        expect { subject.validate! }.to raise_error(Berkshelf::PackageError,
          "Directory is not writable: #{out_dir}")
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
berkshelf-3.1.5 spec/unit/berkshelf/packager_spec.rb
berkshelf-3.1.4 spec/unit/berkshelf/packager_spec.rb
berkshelf-3.1.3 spec/unit/berkshelf/packager_spec.rb
berkshelf-3.1.2 spec/unit/berkshelf/packager_spec.rb
berkshelf-3.1.1 spec/unit/berkshelf/packager_spec.rb
berkshelf-3.1.0 spec/unit/berkshelf/packager_spec.rb
berkshelf-3.0.1 spec/unit/berkshelf/packager_spec.rb
berkshelf-3.0.0 spec/unit/berkshelf/packager_spec.rb
berkshelf-3.0.0.rc1 spec/unit/berkshelf/packager_spec.rb
berkshelf-3.0.0.beta9 spec/unit/berkshelf/packager_spec.rb
berkshelf-3.0.0.beta8 spec/unit/berkshelf/packager_spec.rb
berkshelf-3.0.0.beta7 spec/unit/berkshelf/packager_spec.rb
berkshelf-3.0.0.beta6 spec/unit/berkshelf/packager_spec.rb
berkshelf-3.0.0.beta5 spec/unit/berkshelf/packager_spec.rb