Skip to content

Instantly share code, notes, and snippets.

@rberger
Created October 16, 2014 05:04
Show Gist options
  • Save rberger/7c65937014ba11750e0f to your computer and use it in GitHub Desktop.
Save rberger/7c65937014ba11750e0f to your computer and use it in GitHub Desktop.
How to have an external cookbook's LWRP matcher used in nested describes in Chefspec
require 'chefspec'
require 'chefspec/berkshelf'
describe 'base::default' do
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
it { expect(chef_run).to include_recipe('base::_setup') }
it { expect(chef_run).to include_recipe('base::_route53') }
describe 'base::_setup' do
it { expect(chef_run).to include_recipe('users::sysadmins') }
end
describe 'base::_route53' do
it { expect(chef_run).to include_recipe('route53') }
describe 'route53::default' do
it { expect(chef_run).to create_route53_record(fqdn) }
end
end
end
1) mist_base::default mist_base::_route53 ::route53::default
Failure/Error: it { expect(chef_run).to create_route53_record(fqdn) }
NoMethodError:
undefined method `create_route53_record' for #<RSpec::ExampleGroups::MistBaseDefault::MistBaseRoute53::Route53Default:0x007fb59b7e1208>
# ./spec/default_spec.rb:47:in `block (4 levels) in <top (required)>'
(Line numbers won't match the above example but the line that it was failing on is:
it { expect(chef_run).to create_route53_record(fqdn) }
Because its nesting the route53 recipe (route53::default) in the heirarchy of "describe subjects"
How do I tell Chefspec to not nest it? I tried ::route53::default and it fails the same way
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment