[chef] Re: Chefspec filter recipe eval, or stub include_recipe?


Chronological Thread 
  • From: Eric Wolfe < >
  • To:
  • Cc: Pete Cheslock < >, Zac Stevens < >
  • Subject: [chef] Re: Chefspec filter recipe eval, or stub include_recipe?
  • Date: Wed, 30 Apr 2014 14:12:39 -0400

Yes Pete that does work. Thanks, Pete and Zack!


On Wed, Apr 30, 2014 at 12:08 PM, Pete Cheslock < " target="_blank"> > wrote:
Eric, 

Can you do something like this?  Does this work?


-Pete


On Wed, Apr 30, 2014 at 11:24 AM, Eric Wolfe < " target="_blank"> > wrote:
So I am trying to Chefspec some branching logic in a baseline cookbook.  The recipe chef-client::delete_validation is throwing up an exception on line 28 where it checks for the existence of Chef::Config[:client_key] (https://github.com/opscode-cookbooks/chef-client/blob/master/recipes/delete_validation.rb#L28).  I get several errors like so:

  14) mu-baseline::default On Centos 6.4 as a VMWare guest does include recipe mu-baseline::zenoss_register
     Failure/Error: end.converge(described_recipe)
     TypeError:
       no implicit conversion of nil into String
     # /tmp/d20140430-13074-1bq5osr/cookbooks/chef-client/recipes/delete_validation.rb:28:in `exists?'
     # /tmp/d20140430-13074-1bq5osr/cookbooks/chef-client/recipes/delete_validation.rb:28:in `block (2 levels) in from_file'
     # ./spec/default_spec.rb:43:in `block (3 levels) in <top (required)>'
     # ./spec/default_spec.rb:48:in `block (4 levels) in <top (required)>'

If I just remove `include_recipe 'chef-client::delete_validation'` those test(s) pass.  Is there a way I can filter that recipe's evaluation, or something I can stub, to get past this exception?





Archive powered by MHonArc 2.6.16.

§