Sha256: 193caff089080057987d78d61d68d54886a4ed2c59edd2ad6b46631e8636ed3e

Contents?: true

Size: 1.67 KB

Versions: 42

Compression:

Stored size: 1.67 KB

Contents

require "spec_helper"

describe Pathname do
  describe "#cookbook?" do
    let(:cookbook_path) { tmp_path }
    let(:metadata_rb) { tmp_path.join("metadata.rb") }
    let(:metadata_json) { tmp_path.join("metadata.json") }

    subject { Pathname.new(cookbook_path) }

    context "when the path contains a metadata.json file" do
      before { FileUtils.touch(metadata_json) }

      it "is a cookbook" do
        expect(subject.cookbook?).to be(true)
      end
    end

    context "when the path contains a metadata.rb file" do
      before { FileUtils.touch(metadata_rb) }

      it "is a cookbook" do
        expect(subject.cookbook?).to be(true)
      end
    end

    context "when the path does not contain a metadata.json or metadata.rb file" do
      before { FileUtils.rm_f(metadata_rb) && FileUtils.rm_f(metadata_json) }

      it "is not a cookbook" do
        expect(subject.cookbook?).to be(false)
      end
    end
  end

  describe "#cookbook_root" do
    let(:root_path) { fixtures_path.join("cookbooks", "example_cookbook") }
    let(:cookbook_path) { root_path }
    subject { Pathname.new(cookbook_path) }

    context "when in the root of a cookbook" do
      it "has the correct root" do
        expect(subject.cookbook_root).to eq(root_path)
      end
    end

    context "when in the structure of a cookbook" do
      let(:cookbook_path) { root_path.join("recipes") }

      it "has the correct root" do
        expect(subject.cookbook_root).to eq(root_path)
      end
    end

    context "when not within the structure of a cookbook" do
      let(:cookbook_path) { "/" }

      it "has the correct root" do
        expect(subject.cookbook_root).to be(nil)
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
berkshelf-8.0.15 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-8.0.13 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-8.0.12 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-8.0.9 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-8.0.7 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-8.0.5 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-8.0.2 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-8.0.1 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-8.0.0 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-7.2.2 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-7.2.1 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-7.2.0 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-7.1.0 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-7.0.10 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-7.0.9 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-7.0.8 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-7.0.7 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-6.3.4 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-7.0.6 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-7.0.5 spec/unit/berkshelf/core_ext/pathname_spec.rb