Sha256: 66c01639580635e57023c4a425ed95d7844becb86f4d0cc71b9f9a244b7b6da9

Contents?: true

Size: 1.95 KB

Versions: 532

Compression:

Stored size: 1.95 KB

Contents

require 'spec_helper'
require 'dpl/provider/puppet_forge'
require 'puppet/face'
require 'puppet_blacksmith'

describe DPL::Provider::PuppetForge do
  subject :provider do
    described_class.new(DummyContext.new, :user => 'puppetlabs', :password => 's3cr3t')
  end

  describe "forge" do
    it 'should include the user and password specified' do
      expect(provider.forge.username).to eq(provider.options[:user])
      expect(provider.forge.password).to eq(provider.options[:password])
    end
  end

  describe "build" do
    it 'should use Puppet module tool to build the module' do
      pmt = double('pmt')
      expect(::Puppet::Face).to receive(:[]).and_return(pmt)
      expect(pmt).to receive(:build).with('./')
      provider.build
    end
  end

  describe "#check_auth" do
    it 'should require a user' do
      provider.options.update(:user => nil)
      expect{ provider.check_auth }.to raise_error("must supply a user")
    end

    it 'should require a password' do
      provider.options.update(:password => nil)
      expect{ provider.check_auth }.to raise_error("must supply a password")
    end
  end

  describe "#check_app" do
    it 'should load module metadata using Blacksmith' do
      modulefile = double('modulefile')
      expect(::Blacksmith::Modulefile).to receive(:new).and_return(modulefile)
      expect(modulefile).to receive(:metadata) { true }
      provider.check_app
    end
  end

  describe "#push_app" do
    it 'should use Blacksmith to push to the Forge' do
      forge = double('forge')
      expect(provider).to receive(:build).and_return(true)
      expect(provider).to receive(:modulefile).at_least(:once).and_return(double('modulefile', :name => 'test'))
      expect(provider).to receive(:log).and_return(true)
      expect(::Blacksmith::Forge).to receive(:new).and_return(forge)
      expect(forge).to receive(:push!) { true }
      expect(forge).to receive(:username) { provider.options[:user] }
      provider.push_app
    end
  end
end

Version data entries

532 entries across 532 versions & 3 rubygems

Version Path
dpl-puppet_forge-1.10.17.travis.6637.6 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.16 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.16.travis.6625.6 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.16.travis.6619.6 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.16.travis.5961.5 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.15 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.15.travis.5877.5 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.14 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.13 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.13.travis.4159.5 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.13.travis.4141.5 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.13.travis.4040.5 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.13.travis.4033.5 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.12 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.12.travis.4032.5 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.12.travis.3794.5 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.12.travis.3506.5 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.11.travis.3504.5 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.11 spec/provider/puppet_forge_spec.rb
dpl-puppet_forge-1.10.11.travis.3499.5 spec/provider/puppet_forge_spec.rb