Sha256: d4c941cae754129208fda09ed759d7070df18f854c065e94616c6034e27ad2f9

Contents?: true

Size: 1.8 KB

Versions: 8

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'
require 'r10k/action/puppetfile/purge'

describe R10K::Action::Puppetfile::Purge do
  let(:default_opts) { {root: "/some/nonexistent/path"} }
  let(:puppetfile) do
    instance_double('R10K::ModuleLoader::Puppetfile',
                    :load! => {
                      :modules             => %w{mod},
                      :managed_directories => %w{foo},
                      :desired_contents    => %w{bar},
                      :purge_exclusions    => %w{baz}
                    })
  end

  def purger(opts = {}, argv = [], settings = {})
    opts = default_opts.merge(opts)
    return described_class.new(opts, argv, settings)
  end

  before(:each) do
    allow(R10K::ModuleLoader::Puppetfile).to receive(:new).
      with({basedir: "/some/nonexistent/path"}).
      and_return(puppetfile)
  end

  it_behaves_like "a puppetfile action"

  it "purges unmanaged entries in the Puppetfile moduledir" do
    mock_cleaner = double("cleaner")

    expect(R10K::Util::Cleaner).to receive(:new).
      with(["foo"], ["bar"], ["baz"]).
      and_return(mock_cleaner)

    expect(mock_cleaner).to receive(:purge!)

    purger.call
  end

  describe "using custom paths" do
    it "can use a custom puppetfile path" do
      expect(R10K::ModuleLoader::Puppetfile).to receive(:new).
        with({basedir: "/some/nonexistent/path",
              puppetfile: "/some/other/path/Puppetfile"}).
        and_return(puppetfile)

      purger({puppetfile: "/some/other/path/Puppetfile"}).call
    end

    it "can use a custom moduledir path" do
      expect(R10K::ModuleLoader::Puppetfile).to receive(:new).
        with({basedir: "/some/nonexistent/path",
              moduledir: "/some/other/path/site-modules"}).
        and_return(puppetfile)

      purger({moduledir: "/some/other/path/site-modules"}).call
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
r10k-3.15.0 spec/unit/action/puppetfile/purge_spec.rb
akerl-r10k-3.14.2.1 spec/unit/action/puppetfile/purge_spec.rb
r10k-3.14.2 spec/unit/action/puppetfile/purge_spec.rb
r10k-3.14.1 spec/unit/action/puppetfile/purge_spec.rb
r10k-3.14.0 spec/unit/action/puppetfile/purge_spec.rb
r10k-3.13.0 spec/unit/action/puppetfile/purge_spec.rb
r10k-3.12.1 spec/unit/action/puppetfile/purge_spec.rb
r10k-3.12.0 spec/unit/action/puppetfile/purge_spec.rb