Testing a library which has node attributes #68

retr0h opened this Issue Oct 27, 2012 · 8 comments


None yet

4 participants


Any suggestions on how to test the following?

Since it has node attributes, I was hoping chefspec would mock it out, just like it does for resources.
Any idea what I am missing?

1) Reboot starting to get annoyed
   Failure/Error: @subject.report
     undefined method `node' for nil:NilClass
   # ./cookbooks/reboot-handler/files/default/reboot.rb:9:in `report'
   # ./cookbooks/reboot-handler/spec/reboot_spec.rb:16:in `block (2 levels) in <top (required)>'

Sorry, John, nothing apparent to me. I take it you can confirm that the recipe is indeed being converged?


Appears to be. Obviously I am doing something wrong, and would rather not stub node myself. Hopefully, someone has done this before, can shed some light on this. :)


Hi Jim. I am sorry, but I don't see anything in your repo that tests what I am trying to do.
Thanks for the reply, hoping someone has tested an external file with node attributes before.
Maybe @acrmp can chime in 👍


Hi John,

Here's a modified example that should get you going:


You are good! :) Thank you very much. Was looking for what I was doing wrong. Thanks for helping me with this.

@retr0h retr0h closed this Oct 31, 2012

Hi @acrmp. My apologies, I had one more question. I was looking to test that the command was executed. That seems like a valid test, and also wanted to make sure the node.run_list was reset as per some new requirements in my implementation.

Do you have any recommendations on testing the last 2 tests. Again, my apologies for the silly questions, trying to avoid a bunch of manual stubbing.

@retr0h retr0h reopened this Oct 31, 2012

Ended up figuring it out. Thanks again for your help.

@retr0h retr0h closed this Oct 31, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment