0

I found a way in InSpec to test whether or not python modules have been installed with chef, but I'm using ChefSpec and I can't find an alternative. Does anybody know if there's a way to check if a certain pip module has been installed with ChefSpec?

mjkaufer
  • 4,047
  • 5
  • 27
  • 55

1 Answers1

1

ChefSpec doesn't test side effects, so you don't check the module itself, you look at what resources were scheduled for execution. If you're using poise-python, that would mean a test like:

it { is_expected.to install_python_package('foo') }
coderanger
  • 52,400
  • 4
  • 52
  • 75
  • thanks! This is definitely what I want, but when I include it in my tests I get an error `NoMethodError: undefined method 'find_resource' for "(my test context)":String` - it points to the line with your statement as having the error (I replaced `foo` with an actual package). Do you know what might be causing this issue? – mjkaufer Aug 10 '17 at 18:34
  • Using `is_expected` assumes you have `subject { ChefSpec...converge(described_recipe) }`. If you use a different `let` variable, you'll need to adjust the RSpec-y bits. – coderanger Aug 10 '17 at 22:02