amfranz / rspec-hiera-puppet Goto Github PK
View Code? Open in Web Editor NEWHiera fixtures for puppet-rspec tests.
License: MIT License
Hiera fixtures for puppet-rspec tests.
License: MIT License
With the following example rspec:
context "test" do
let :hiera_data do
{ :test => "fu" }
end
it { should contain_notify("foo").with_message("fu") }
end
context "test-2" do
let :hiera_data do
{ :test => "bar" }
end
it { should contain_notify("foo").with_message("bar") }
end
The first and second will pass if run individually but when run one after the other it appears that hiera_data in the second context (:test => "bar") is not set and that the first one is still used (:test => "fu").
Hi,
I can't tell if I'm doing something terribly stupid but when I try to just let(:hiera_data) it fails as you can see below. This is with just a gem install (as well as a gem install from a package made out of git just in case):
Failures:
apenney@archlinux ~/git/configuration/modules/lms$ cat spec/classes/config_spec.rb
require 'spec_helper'
describe "lms::config" do
let(:params) { {
:virtualenv => '/opt/edx',
} }
context 'with ::edx set to true' do
let(:facts) { {:edx => true, :ssh_content_deploy => 'keyhere' } }
let(:hiera_data) { { :ssh_content_deploy => 'beep' } }
it do
should contain_edx__admin('content_deploy').with(
'public_key' => 'keyhere',
)
end
end
end
apenney@archlinux ~/git/configuration/modules/lms$ cat spec/spec_helper.rb
require 'rubygems'
require 'rspec-hiera-puppet'
require 'puppetlabs_spec_helper/module_spec_helper'
The catalog is being built wrong on boolean values.
if you have in the manifest:
$should_do = str2bool(hiera('should_do'))
if $should_do {
notify { 'should': message => '$should_do was true', }
} else {
notify { 'should_not': message => '$should_do was false', }
}
This test passes correctly:
let($hiera_data) { { :should_do => 'true' } }
it { should contain_notify('should') }
it { should_not contain_notify('should_not') }
This test fails incorrectly:
let($hiera_data) { { :should_do => 'false' } }
it { should_not contain_notify('should') }
it { should contain_notify('should_not') }
Hi,
On my RHEL machine I have puppet and facter installed via RPMS. When I installed rspec-hiera-puppet (via gem) it forcibly installed both gems slapping itself on top of the rpm copies. Is there any chance you could remove this (or detect puppet differently) for people with packaged versions?
I am not sure with which version of rspec-puppet the break first occurs but the 1.0.1 does not work (unit tests), 0.1.6 does work.
The error
Error: Error from DataBinding 'hiera' while looking up '*first parameter *' : no implicit conversion of Hash into String on node XXXXXX
It does not matter if the parameter is using hiera or not, you can even take out all mention of hiera and you will still get the error as long as long as spec_helper.rb contains require 'rspec-hiera-puppet'.
Googling this error it seems this is one of those errors that gives you bad info and misdirects, it has nothing to do with hash but a badly formed hiera file.... at least in the context of getting this on a normal puppet apply and not a unit test.
I'm trying to unit-test using this gem...
Have a look at this
This is the order in which I expect hiera to choose values:
riak::vmargs
class spec's :params
riak::vmargs
class spec's :hiera_data
shared_context 'hieradata'
's :hiera_data
riak::params
riak::vmargs( $absent = hiera('absent', 'false') )
- the default just by the class parameterBut it seems that the default value from the hiera function overrides everything from within the rspec's hiera_data
.
Perhaps @haus could have a look at this as well?
I might be doing something wrong...
To try it:
bundle
bundle exec rake specs
Hi there,
i tried for some hours but cannot even get the basic example from the Readme to do anything - I basically always end up with a
Could not find data item foo_message in any Hiera data file and no default supplied
For what I can tell the configuration bits to hiera_config never make it into my puppet environment (unless I directly assign a file to Puppet.settings[:hiera_config]). The backend itself appears to work.
pls see https://gist.github.com/4198268
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.