By Greg Sypolt
I recently had the opportunity to get involved with Chef cookbook development, and begin learning how to write some tests for infrastructure code by using various testing frameworks. One critical aspect of developing any code is writing unit tests. We use ChefSpec - it's a unit testing framework for testing Chef cookbooks.
ChefSpec is simple to write. It reads a whole lot easier than other unit testing frameworks, and provides fast feedback on cookbook changes without the need for a virtual machine or cloud machine.
Below, I'll show off ChefSpec in action. I'll do that by first setting up a workstation to run Chef locally, then use the existing Chef community cookbook to deploy the application on the local workstation environment. Finally, I'll walk through some of the unit to make sure everything is working properly.
Read the entire blog post here: https://saucelabs.com/blog/unit-testing-chef-cookbooks-with-chefspec