chef-boneyard/minitest-chef-handler

Assertions

Closed this issue · 6 comments

Hi David,

The assertions you provide don't actually test the system directly correct? They are only testing the resources were defined and that if chef ran correctly it should have installed X package. The assert_installed for example doesn't actually check the system to see if chef really did install it correct?

Thanks,
Jay

You're completely right. I'll see what I can do this weekend, I'm kind of busy with the new gig this week.

Cool. Thanks! Congrats on your new gig.

Hi guys,

The assertions themselves don't load the state of the box - it's passed into the assertion.

These two lines are equivalent:

# MiniTest::Spec
package("foo").must_be_installed

# MiniTest::Unit
assert_installed(package("foo"))

The package method you have access to in your tests is actually going to the system to find out the current state - it doesn't look at the resources defined in your Chef run.

Cheers,

Andrew.

Hi Andrew,

Thanks for checking this. Can you point me to where the package method exists? I'd just like to see the code that is being executed?

Thanks,
Jay

Chef already contains the logic for loading the current state of a resource so we use that:
https://github.com/calavera/minitest-chef-handler/blob/v0.4.0/lib/minitest-chef-handler/resources.rb#L24

Thanks!