Sha256: 9c7332aa762ca29a1cbf924ef42275cc728ac3b6af582e4356713a960cebf7f8

Contents?: true

Size: 1.64 KB

Versions: 26

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

module Berkshelf
  describe PathLocation do
    let(:complacent_constraint) { double('comp-vconstraint', satisfies?: true) }
    let(:path) { fixtures_path.join("cookbooks", "example_cookbook").to_s }
    subject { 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 { 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 { 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 { 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

26 entries across 26 versions & 1 rubygems

Version Path
berkshelf-1.1.6 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.1.5 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.1.4 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.1.3 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.1.2 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.1.1 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.1.0 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.1.0.rc1 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.0.4 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.0.3 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.0.2 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.0.0 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.0.0.rc3 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.0.0.rc2 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-1.0.0.rc1 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-0.6.0.beta4 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-0.6.0.beta3 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-0.6.0.beta2 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-0.5.1 spec/unit/berkshelf/locations/path_location_spec.rb
berkshelf-0.6.0.beta1 spec/unit/berkshelf/locations/path_location_spec.rb