Hi, I hope this on-topic. Let me know if I should post this somewhere more appropriate.
I'm using rspec-puppet, puppetlabs_spec_helper, and a fork of hiera-puppet-helper* while developing a new module for puppet 3.4 and ran into an issue I don't understand. I have posted a mock-up of the module on Github, here...<https://github.com/dayglojesus/test-foo> Admittedly, the module uses an unconventional pattern, but I think it should work. # init.pp class foo { $bar_options = is_hash(hiera('foo::bar::options', false)) if $bar_options == true { contain foo::bar } } # bar.pp class foo::bar ($options) { validate_hash($options) } Basically, I want to contain the class 'foo::bar' if hiera supplies a hash for 'foo::bar::options'. If not, we simply compile without it. In my spec for the foo class, I have two contextual tests: # spec/classes/foo_spec.rb describe 'foo', :type => 'class' do context "when there are no BAR options set" do it { should_not contain_class("foo::bar") } end context "when BAR configuration options are set" do hash = { 'some_key' => "Some Value" } let :hiera_data do { 'foo::bar::options' => hash } end it { should contain_class('foo::bar') } end end I would expect that both these tests pass, but the second test always fails. However, if I remove the first contextual test and just do: # spec/classes/foo_spec.rb describe 'foo', :type => 'class' do context "when BAR configuration options are set" do hash = { 'some_key' => "Some Value" } let :hiera_data do { 'foo::bar::options' => hash } end it { should contain_class('foo::bar') } end end The test passes. And, as you might guess, if I change :hiera_data to something other than a hash, the same test fails: # spec/classes/foo_spec.rb describe 'foo', :type => 'class' do context "when BAR configuration options are set" do hash = false let :hiera_data do { 'foo::bar::options' => hash } end it { should contain_class('foo::bar') } end end # This fails, as it should. It is only when I test both contexts that ONE of them fails -- the second one always fails. Is this a bug or am I missing something more fundamental? Thanks, -- B. *Source for hiera-puppet-helper is: "git://github.com/mmz-srf/hiera-puppet-helper.git" which patches this gem for use with Puppet >= 3.4.0 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/b6a07285-edfb-4ed7-b11e-5af8f9e2e02c%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
