Created
September 30, 2012 19:19
-
-
Save retr0h/3808196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In default.rb from cookbook being tested | |
# node.run_state['reboot'] = true | |
it "flags system to reboot" do | |
chef_run.node.run_state['reboot'].should_be true | |
end |
Awesome! I owe you a beer! :)
That works. Thanks much for your help. I feel like I'm cheating a bit.
It's nice to know my 'update-grub' execute is the one making the call to the 'setting reboot flag' resource.
Maybe, there is no good way to test that.
With modern versions of ChefSpec the following works:
chef_run.find_resource(:ruby_block, 'my ruby_block name').old_run_action(:create)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi John,
This is because the
run_state
is modified within aruby_block
. Chefspec treatsruby_block
resources the same as any other resource - it doesn't actually apply the resource.If you specifically want to converge a resource you can do something like the following (there is probably a nicer way of expressing this):