Created
May 3, 2016 17:02
-
-
Save cdenneen/3d170620ccfc38b5b077d9baeaf2cf94 to your computer and use it in GitHub Desktop.
RSpec testing for ingester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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