Sha256: 91c61f8f590cf2bc3582e1b9fdee50cc1d80adedb3b3a414bf3beb1a21e5ca29

Contents?: true

Size: 1.72 KB

Versions: 4

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

module Berkshelf
  describe CookbookSource::PathLocation do
    let(:complacent_constraint) { double('comp-vconstraint', satisfies?: true) }
    let(:path) { fixtures_path.join("cookbooks", "example_cookbook").to_s }
    subject { CookbookSource::PathLocation.new("nginx", complacent_constraint, path: path) }

    describe "#download" do
      it "returns an instance of CachedCookbook" do
        subject.download(tmp_path).should be_a(CachedCookbook)
      end

      it "sets the downloaded status to true" do
        subject.download(tmp_path)

        subject.should be_downloaded
      end

      context "given a path that does not exist" do
        subject { CookbookSource::PathLocation.new("doesnot_exist", complacent_constraint, path: tmp_path.join("doesntexist_noway")) }

        it "raises a CookbookNotFound error" do
          lambda {
            subject.download(tmp_path)
          }.should raise_error(CookbookNotFound)
        end
      end

      context "given a path that does not contain a cookbook" do
        subject { CookbookSource::PathLocation.new("doesnot_exist", complacent_constraint, path: fixtures_path) }

        it "raises a CookbookNotFound error" do
          lambda {
            subject.download(tmp_path)
          }.should raise_error(CookbookNotFound)
        end
      end

      context "given the content at path does not satisfy the version constraint" do
        subject { CookbookSource::PathLocation.new("nginx", double('constraint', satisfies?: false), path: path) }

        it "raises a ConstraintNotSatisfied error" do
          lambda {
            subject.download(double('path'))
          }.should raise_error(ConstraintNotSatisfied)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
berkshelf-0.4.0.rc4 spec/unit/berkshelf/cookbook_source/path_location_spec.rb
berkshelf-0.4.0.rc3 spec/unit/berkshelf/cookbook_source/path_location_spec.rb
berkshelf-0.4.0.rc2 spec/unit/berkshelf/cookbook_source/path_location_spec.rb
berkshelf-0.4.0.rc1 spec/unit/berkshelf/cookbook_source/path_location_spec.rb