I'm just going to jump straight into the reproduction scenario. Brand new cookbook, blank recipe, blank attributes, etc. Using Policyfile rather than Berks for dependency management (not sure if that's relevant, but I haven't used Berks in a while and haven't bothered to test out this repro with Berks). Only dependency declared in metadata.rb is depends 'runit'.
spec/unit/recipes/default_spec.rb:
require 'chefspec'
require 'chefspec/policyfile'
describe 'my_cookbook::default' do
context 'When on RHEL 7.3' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'redhat', version: '7.3').converge(described_recipe)
end
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
end
context 'When on RHEL 7.2' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'redhat', version: '7.2').converge(described_recipe)
end
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
end
end
And here is the output from running ChefSpec tests:
$ chef exec rspec -fd --color
my_cookbook::default
When on RHEL 7.3
[2017-11-28T11:00:20-07:00] WARN: RunitService already exists! Deprecation class overwrites Custom resource runit_service from cookbook runit
converges successfully
When on RHEL 7.2
converges successfully (FAILED - 1)
Failures:
1) my_cookbook::default When on RHEL 7.2 converges successfully
Failure/Error: expect { chef_run }.to_not raise_error
expected no Exception, got #<TypeError: superclass mismatch for class RunitService> with backtrace:
# /tmp/d20171128-16945-1s7pyc0/cookbook_artifacts/runit-210c8f27a7c2e8d9afa591cb7f55c658a7482b25/libraries/resource_runit_service.rb:27:in `<class:Resource>'
# /tmp/d20171128-16945-1s7pyc0/cookbook_artifacts/runit-210c8f27a7c2e8d9afa591cb7f55c658a7482b25/libraries/resource_runit_service.rb:25:in `<class:Chef>'
# /tmp/d20171128-16945-1s7pyc0/cookbook_artifacts/runit-210c8f27a7c2e8d9afa591cb7f55c658a7482b25/libraries/resource_runit_service.rb:24:in `<top (required)>'
# ./spec/unit/recipes/default_spec.rb:17:in `block (3 levels) in <top (required)>'
# ./spec/unit/recipes/default_spec.rb:21:in `block (4 levels) in <top (required)>'
# ./spec/unit/recipes/default_spec.rb:21:in `block (3 levels) in <top (required)>'
# ./spec/unit/recipes/default_spec.rb:21:in `block (3 levels) in <top (required)>'
Finished in 1.27 seconds (files took 0.81392 seconds to load)
2 examples, 1 failure
Failed examples:
rspec ./spec/unit/recipes/default_spec.rb:20 # my_cookbook::default When on RHEL 7.2 converges successfully
The choice of platforms is irrelevant, I can switch the ordering, use different platforms, or use the same platforms for both contexts and still I get the same error. Any scenario I can concoct that uses multiple describe or context blocks triggers the error.
If I version-restrict the runit cookbook to < 4.0.0 in metadata.rb, or if I remove runit from the cookbook's dependencies altogether, I do not get this error.
I'm just going to jump straight into the reproduction scenario. Brand new cookbook, blank recipe, blank attributes, etc. Using Policyfile rather than Berks for dependency management (not sure if that's relevant, but I haven't used Berks in a while and haven't bothered to test out this repro with Berks). Only dependency declared in
metadata.rb
isdepends 'runit'
.spec/unit/recipes/default_spec.rb
:And here is the output from running ChefSpec tests:
The choice of platforms is irrelevant, I can switch the ordering, use different platforms, or use the same platforms for both contexts and still I get the same error. Any scenario I can concoct that uses multiple
describe
orcontext
blocks triggers the error.If I version-restrict the runit cookbook to < 4.0.0 in metadata.rb, or if I remove runit from the cookbook's dependencies altogether, I do not get this error.