Sha256: 99ca2f7b2dc5e7845baeb1b207170d335117c454ae860c9eaed7219ed8f1088e

Contents?: true

Size: 1.39 KB

Versions: 19

Compression:

Stored size: 1.39 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) }
      its(:cookbook?) { should be_true }
    end

    context "when the path contains a metadata.rb file" do
      before { FileUtils.touch(metadata_rb) }
      its(:cookbook?) { should be_true }
    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) }
      its(:cookbook?) { should be_false }
    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
      its(:cookbook_root) { should eql(root_path) }
    end

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

    context "when not within the structure of a cookbook" do
      let(:cookbook_path) { "/" }
      its(:cookbook_root) { should be_nil }
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
berkshelf-3.1.5 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-3.1.4 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-2.0.18 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-2.0.17 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-3.1.3 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-3.1.2 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-2.0.16 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-3.1.1 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-3.1.0 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-3.0.1 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-3.0.0 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-2.0.15 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-3.0.0.rc1 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-3.0.0.beta9 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-3.0.0.beta8 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-3.0.0.beta7 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-3.0.0.beta6 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-2.0.14 spec/unit/berkshelf/core_ext/pathname_spec.rb
berkshelf-3.0.0.beta5 spec/unit/berkshelf/core_ext/pathname_spec.rb