Sha256: 6a2ed3c61c1b4a1782d3b8397ea9555e0c77967f2b1ff5ad2644f824bcfab020

Contents?: true

Size: 1.62 KB

Versions: 7

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

require 'r10k/deployment'
require 'r10k/action/deploy/environment'

describe R10K::Action::Deploy::Environment do

  subject { described_class.new({config: "/some/nonexistent/path"}, []) }

  it_behaves_like "a deploy action that can be write locked"
  it_behaves_like "a deploy action that requires a config file"

  describe "initializing" do
    it "can accept a cachedir option" do
      described_class.new({cachedir: "/some/nonexistent/cachedir"}, [])
    end

    it "can accept a puppetfile option" do
      described_class.new({puppetfile: true}, [])
    end

    it "normalizes environment names in the arg vector"
  end

  describe "when called" do
    describe "with an environment that doesn't exist" do
      let(:config) do
        R10K::Deployment::MockConfig.new(
          :sources => {
            :control => {
              :type => :mock,
              :basedir => '/some/nonexistent/path/control',
              :environments => %w[first second third],
            }
          }
        )
      end

      let(:deployment) do
        R10K::Deployment.new(config)
      end

      before do
        expect(R10K::Deployment).to receive(:new).and_return(deployment)
      end

      subject { described_class.new({config: "/some/nonexistent/path", purge: false}, %w[not_an_environment]) }

      it "logs that the environments can't be deployed and returns false" do
        expect(subject.logger).to receive(:error).with("Environment(s) 'not_an_environment' cannot be found in any source and will not be deployed.")
        logger = subject.logger
        expect(subject.call).to eq false
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
r10k-2.3.1 spec/unit/action/deploy/environment_spec.rb
r10k-2.3.0 spec/unit/action/deploy/environment_spec.rb
r10k-2.2.2 spec/unit/action/deploy/environment_spec.rb
r10k-2.2.1 spec/unit/action/deploy/environment_spec.rb
r10k-2.2.0 spec/unit/action/deploy/environment_spec.rb
r10k-2.1.1 spec/unit/action/deploy/environment_spec.rb
r10k-2.1.0 spec/unit/action/deploy/environment_spec.rb