Hi Folks,
I'm new to puppet and rspec and like to write a unit test that checks if an
fail message is raised in case my module is run on non-supported operating
system, so I wrote something like the code below, but I end-up if an error
of 'No matching value for selector Darwin'.
# my_module/manifests/init.pp
class myclass inherits myclass::params {
case $::operatingsystem {
debian, ubuntu: {}
default: { fail("${::hostname}: Module ${::module_name} does not
support operatingsystem ${::operatingsystem}") }
}
}
# spec/classes/init_spec.rb
require 'spec_helper'
describe "graylog2", :type => 'class' do
context 'On ubuntu systems' do
let(:facts) { {:operatingsystem => 'Ubuntu', :kernel => 'Linux'} }
it {should include_class('myclass::params')}
end
context 'On non-ubuntu systems' do
let(:facts) { {:operatingsystem => 'Darwin', :kernel => 'Linux'} }
it do
expect {
should include_class('myclass::params')
}.to raise_error(Puppet::Error, /does not support operatingsystem/)
end
end
end
How should I write such test?
Thanks for the help,
Eric
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.