Skip to content

Instantly share code, notes, and snippets.

@cdenneen
Created May 3, 2016 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdenneen/3d170620ccfc38b5b077d9baeaf2cf94 to your computer and use it in GitHub Desktop.
Save cdenneen/3d170620ccfc38b5b077d9baeaf2cf94 to your computer and use it in GitHub Desktop.
RSpec testing for ingester
require 'spec_helper'
require 'pry'
describe 'profile::ingester' do
on_supported_os({
supported_os: [
{
'operatingsystem' => 'CentOS',
'operatingsystemrelease' => [
'5',
'6',
'7'
]
}
]
}).each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge({
puppetversion: Puppet.version,
ap_env: 'dev',
ap_region: 'us-east-1',
role: 'ingester'
})
end
role = facts[role]
puts "My Role is #{role}"
puts "My FactsRole is #{facts[role]}"
puts "My FactsRole2 is #{facts[:role]}"
scope = YAML.load('role: ingester')
hiera = Hiera.new(:config => 'spec/fixtures/hiera.yaml')
modules = hiera.lookup('nodejs::npm', "role/%{role}", scope)
modules.each do |title, mod|
mod_name = mod['package']
mod_version = mod['ensure']
context "with #{mod_name} (#{title}) set to #{mod_version}" do
it { should contain_nodejs__npm(title).with_ensure(mod_version) }
end
end
%w(profile::ingester).each do |puppet_class|
it { is_expected.to contain_class(puppet_class) }
end
provider_class = Puppet::Type.type(:package).provider(:rpm)
before :each do
Puppet::Type.type(:package).stubs(:defaultprovider).returns(provider_class)
end
it { is_expected.to compile.with_all_deps }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment