Getting started with ChefSpec

In order to get started with ChefSpec, create a new cookbook directory (here it is $HOME/cookbooks/mycookbook) along with a recipes and spec directory:

mkdir -p ~/cookbooks/mycookbook 
mkdir -p ~/cookbooks/mycookbook/recipes
mkdir -p ~/cookbooks/mycookbook/spec

Now you will need a simple metadata.rb file inside your cookbook (here, this will be ~/cookbooks/mycookbook/metadata.rb):

maintainer       "Your name here"
maintainer_email "you@domain.com"
license          "Apache"
description      "Simple cookbook"
long_description "Super simple cookbook"
version          "1.0"
supports         "debian"

Once we have this, we now have the bare bones of a cookbook that we can begin to add recipes and tests to.

Installing ChefSpec

In order to get started with ChefSpec, ...

Get Chef: Powerful Infrastructure Automation now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.