chef-boneyard / minitest-chef-handler

Run minitest suites after your Chef recipes to check the status of your system.
Other
163 stars 44 forks source link

Add a which method so tests can assert if a command was installed #37

Closed jtimberman closed 9 years ago

jtimberman commented 12 years ago

In testing behavior of cookbooks, it is desirable to check to see if a specific command is available in the default $PATH. For example, the zsh cookbook by Opscode simply installs zsh, and the best post-convergence test is whether zsh is available to run. We have this "which" method (via stackoverflow):

https://github.com/opscode-cookbooks/zsh/blob/master/files/default/tests/minitest/support/helpers.rb#L7-18

I'm happy to add this and send a pull request, but I don't know where it best fits.

leifmadsen commented 12 years ago

It kind of looks like it might fit into the lib/minitest-chef-handler/resources.rb file? Probably then needs to be expanded in the assertions.rb and infections.rb, but it's almost certain I'm way off :)

calavera commented 12 years ago

Yeah, I think it would fit well into the resource. Your implementation has a bug on windows though, in the line 13 you're using / to concat path and command, you should use File.join that uses the specific file separator.

jtimberman commented 12 years ago

It may be worth using @erikh's which gem for this:

erikh commented 12 years ago

It's a pretty small gem. If you find the code suitable no need to add a dependency, just bring it in. :)

erikh commented 12 years ago

It doesn't handle PATHEXT properly on windows, but shouldn't be much work to fix that.