forked from rodjek/rspec-puppet
-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Description
Describe the Bug
With a defined that has a default parameter which uses a fact for the default value e.g.
define example::rspec_define (
$fact_parameter = $facts['os']['distro']['codename']
) {
file{'/tmp/T291374':
ensure => file,
content => $fact_parameter
}
}Testing using rspec-puppet-tests has no affect on the default value. It appears that all tests use the last value in the on_supported_os iterator.
The test i used is:
describe 'example::rspec_define' do
on_supported_os(test_on).each do |os, facts|
let(:facts) { facts }
let(:title) { "test-#{os}" }
context os do
context 'test' do
it { is_expected.to compile }
it { is_expected.to contain_file('/tmp/T291374').with_content(/#{facts[:os]['distro']['codename']}/) }
end
end
end
endExpected Behaviour
All test should pass
Actual Behaviour
The file content test above fails when testing debian-10-x86_64 with the following error
1) example::rspec_define debian-10-x86_64 test is expected to contain File[/tmp/T291374] with content =~ /buster/
Failure/Error: it { is_expected.to contain_file('/tmp/T291374').with_content(/#{facts[:os]['distro']['codename']}/) }
expected that the catalogue would contain File[/tmp/T291374] with content set to /buster/ but it is set to "stretch"
# ./spec/defines/rspec_define_spec.rb:10:in `block (5 levels) in <top (required)>'
Steps to Reproduce
I have created a specific repo to demonstrate this issue
Steps to reproduce the behavior:
git clone https://github.com/b4ldr/T291374/cd T291374bundle installbundle exec rake spec
Metadata
Metadata
Assignees
Labels
No labels