Skip to content

Latest commit

 

History

History
69 lines (61 loc) · 1.87 KB

TESTING.md

File metadata and controls

69 lines (61 loc) · 1.87 KB

Cookbook TESTING doc

Bundler

A ruby environment with Bundler installed is a prerequisite for using the testing harness shipped with this cookbook. At the time of this writing, it works with Ruby 1.9.3 and Bundler 1.6.2. All programs involved, with the exception of Vagrant, can be installed by cd'ing into the parent directory of this cookbook and running "bundle install"

Rakefile

The Rakefile ships with a number of tasks, each of which can be ran individually, or in groups. Typing "rake" by itself will perform style checks with Rubocop and Foodcritic, ChefSpec with rspec, and integration with Test Kitchen using the Vagrant driver by default.Alternatively, integration tests can be ran with Test Kitchen cloud drivers.

$ rake -T
rake integration:vagrant  # Run Test Kitchen with Vagrant
rake style                # Run all style checks
rake style:chef           # Lint Chef cookbooks
rake style:ruby           # Run Ruby style checks

Style Testing

Ruby style tests can be performed by Rubocop by issuing either

bundle exec rubocop

or

rake style:ruby

Chef style tests can be performed with Foodcritic by issuing either

bundle exec foodcritic

or

rake style:chef

Integration Testing

Integration testing is performed by Test Kitchen. After a successful converge, tests are uploaded and ran out of band of Chef. Tests should be designed to ensure that a recipe has accomplished its goal.

Integration Testing using Vagrant

Integration tests can be performed on a local workstation using Virtualbox or VMWare. Detailed instructions for setting this up can be found at the Bento project web site.

Integration tests using Vagrant can be performed with either

bundle exec kitchen test

or

rake integration:vagrant