[chef] Re: Re: Re: Re: Re: Re: Re: Re: ChefSpec for LWRPs without recipes...


Chronological Thread 
  • From: Bryan Stenson < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: Re: Re: Re: Re: ChefSpec for LWRPs without recipes...
  • Date: Thu, 2 May 2013 08:00:22 -0700

I think I've not been clear on what I'm advocating, or why I'm confused.

I'm 100% behind testing cookbooks and LWRPs.  Clearly, it's the distinguishing factor between "hacking" and professionalism.  I'm even 100% behind including the tests with the cookbook (in the spec/testing/etc folders in the root of the cookbook).

What I'm arguing against is the need for creating a "_test_myLWRP.rb" recipe in the "/cookbooks/mylibrarycookbook/recipes/" folder.

If a recipe is in that folder, it should be suitable for use by any other cookbook/role/run_list.  A "_test_myLWRP.rb" recipe would ONLY be useful for testing "myLWRP.rb" in "/cookbooks/mylibrarycookbook/{resource|provider}" directories, and SHOULDN'T be in the general "/cookbooks/mylibrarycookbook/recipes" folder.

It's the equivalent of putting a RSpec file in your RoR lib directory, or including JUnit test class in your java classpath during normal execution.

My conclusion?  Chefspec needs a way to test LWRPs without the creating a "real" recipe (similar to what rspec-chef does - thanks Zac!)

I'm suggesting a mechanism which allows Chefspec to inject "fixture recipes" into "/cookbooks/mylibrarycookbook/recipes" dynamically, before handing execution to ChefRunner.  One possibly layout might be:

/cookbooks
  /mylibrarycookbook
    /recipes
      (empty - or perhaps an empty default.rb recipe)
  /providers
    myLWRP.rb
  /resources
    myLWRP.rb
  /spec
    default_spec.rb
    /fixtures
      /recipes
        testing_myLWRP.rb

"testing_myLWRP.rb" would be copied into the "/mylibrarycookbook/recipes" for the purpose of the Chefspec run, but wouldn't be there for general LWRP consumption.

Anyway, I think this is a pretty fundamental need, and I haven't found a great way to do it yet.  Perhaps I'll file feature request and dabble until I've got something worth of a pull request.

Bryan



Archive powered by MHonArc 2.6.16.

§