Sha256: 91c83b68e6e63a91ed43958e149867682d9cacf20baaf760882afc915e4cd8d2

Contents?: true

Size: 1.46 KB

Versions: 105

Compression:

Stored size: 1.46 KB

Contents

require "spec_helper"

describe CFManifests::Builder do
  subject { CFManifests::Loader.new(nil, nil) }

  describe "#build" do
    let(:file) { "manifest.yml" }

    before do
      FakeFS.activate!

      File.open(file, "w") do |io|
        io.write manifest
      end
    end

    after do
      FakeFS.deactivate!
      FakeFS::FileSystem.clear
    end

    context "with a simple manifest" do
      let(:manifest) do
        <<EOF
---
foo: bar
EOF
      end

      it "loads the manifest YAML" do
        expect(subject.build(file)).to eq("foo" => "bar")
      end
    end

    context "with a manifest that inherits another" do
      let(:manifest) do
        <<EOF
---
inherit: other-manifest.yml
foo:
  baz: c
EOF
      end

      before do
        FakeFS.activate!

        File.open("other-manifest.yml", "w") do |io|
          io.write <<OTHER
---
foo:
  bar: a
  baz: b
OTHER
        end
      end

      it "merges itself into the parent, by depth" do
        manifest = subject.build(file)
        expect(manifest).to include(
          "foo" => { "bar" => "a", "baz" => "c" })
      end

      it "does not include the 'inherit' attribute" do
        manifest = subject.build(file)
        expect(manifest).to_not include("inherit")
      end
    end

    context "with an invalid manifest" do
      let(:manifest) { "" }

      it "raises an error" do
        expect {
          subject.build(file)
        }.to raise_error(CFManifests::InvalidManifest)
      end
    end
  end
end

Version data entries

105 entries across 105 versions & 2 rubygems

Version Path
cf-5.4.7 spec/manifests/loader/builder_spec.rb
cf-5.4.7.rc1 spec/manifests/loader/builder_spec.rb
cf-5.4.5 spec/manifests/loader/builder_spec.rb
cf-5.4.4 spec/manifests/loader/builder_spec.rb
trucker-cli-0.0.3 spec/manifests/loader/builder_spec.rb
cf-5.4.3 spec/manifests/loader/builder_spec.rb
cf-5.4.2 spec/manifests/loader/builder_spec.rb
trucker-cli-0.0.2 spec/manifests/loader/builder_spec.rb
trucker-cli-0.0.1 spec/manifests/loader/builder_spec.rb
cf-5.4.1 spec/manifests/loader/builder_spec.rb
cf-5.4.1.rc1 spec/manifests/loader/builder_spec.rb
cf-5.4.0 spec/manifests/loader/builder_spec.rb
cf-5.3.1 spec/manifests/loader/builder_spec.rb
cf-5.3.0 spec/manifests/loader/builder_spec.rb
cf-5.2.2 spec/manifests/loader/builder_spec.rb
cf-5.2.1.rc15 spec/manifests/loader/builder_spec.rb
cf-5.2.1.rc14 spec/manifests/loader/builder_spec.rb
cf-5.2.1.rc13 spec/manifests/loader/builder_spec.rb
cf-5.2.1.rc12 spec/manifests/loader/builder_spec.rb
cf-5.2.1.rc11 spec/manifests/loader/builder_spec.rb