Test Driven Chef Cookbooks With Meez

When cooking a new dish, things get out of control if you try to manage too many things at once

You might face a similar situation when trying to write a new Chef cookbook.

Getting your arms around all those tools and frameworks needed to write solid, tested cookbooks gets you spinning. You need to install Food Critic, Chef Spec, Berkshelf – and the list goes on. This set up can easily take up to half a day or more.

French Chefs arrange all the ingredients which they’ll need well before they start cooking. They call this set up procedure „Mise en place“, or in short „Meez“.

And you should do the same

That’s what Meez is all about. It’s a Ruby Gem which creates a cookbook for you which has puts all these tools in place before you start cooking. Now you can work like a professional Chef concentrating on the recipe at hand instead of juggling new tools.

Meez needs a Ruby installation

Meez manages all dependencies using Bundler. To install it on your box run:

gem install bundler

Additionally, make sure you’ve got VirtualBox and Vagrant installed, too.

Let’s create a cookbook called my_cookbook using Meez

  1. Install the Meez Gem:$ gem install meez
    https://gist.github.com/mmarschall/8811327.js
  2. Let’s ask meez to create our cookbook:
    $ meez -C "Matthias Marschall" -m mm@agileweboperations.com -I apachev2 my_cookbook
    https://gist.github.com/mmarschall/8811349.js
  3. Time to install all required gems:
    $ cd ./cookbooks/my_cookbook
    $ bundle install

    https://gist.github.com/mmarschall/8811376.js
  4. Install all dependent cookbooks using Berkshelf:
    $ bundle exec berks installhttps://gist.github.com/mmarschall/8811396.js
  5. Time to run all auto-generated test suites:$ bundle exec strainer test

    https://gist.github.com/mmarschall/8811404.js

Start writing your cookbook

If you add new dependencies to your metadata.rb, you need to run bundle exec berks install again.

Then you can re-run your complete test suite using bundle exec strainer test

Read more about the ideas behind Meez in The Lazy SysAdmin’s Guide to Test Driven Chef Cookbooks written by the author of Meez: Paul Czarkowski (@pczarkowski)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.