1

I have a recipe that depends on the apache2 cookbook to, among other things, enable a module using the definition:

apache_module 'passenger'

Is there a way to test that call with chefspec ?

According to "Chef libraries or definitions?", a definition is just a grouping of several resources.

Should I add expectations for each resource added by the definition ?
Or is that testing 3rd party code ?

Community
  • 1
  • 1
patatepartie
  • 178
  • 1
  • 6

1 Answers1

5

You cannot test definition calls with ChefSpec. As definitions do not actually exist in the resource collection, you can't assert they have been called. You could assert than an object contained in the definition is called.

Sources:

  • I wrote it
sethvargo
  • 26,739
  • 10
  • 86
  • 156
  • 2
    Thank you, @sethvargo. That's what I thought. I'll resort to asserting on one resource in the definition, as you suggested, even if it feels a bit like testing the definition itself and not its call. – patatepartie Apr 10 '14 at 00:51