Skip to content

Latest commit

 

History

History
68 lines (45 loc) · 1.36 KB

TESTING.md

File metadata and controls

68 lines (45 loc) · 1.36 KB

Cookbook testing

Testing Prerequisites

A working ChefDK installation set as your system's default ruby. ChefDK can be downloaded at https://downloads.chef.io/chef-dk/

Hashicorp's Vagrant and Oracle's Virtualbox for integration testing.

Installing dependencies

chef exec bundle install

Update any installed dependencies to the latest versions:

chef exec bundle update

Rakefile

$ chef exec rake -T
rake spec                     # Run ChefSpec examples
rake style                    # Run all style checks
rake style:chef               # Run Chef style checks
rake style:ruby               # Run Ruby style checks
rake style:ruby:auto_correct  # Auto-correct RuboCop offenses
rake test                     # Run all tests

Style Testing

Ruby style tests can be performed by Rubocop by issuing either

chef exec rake style:ruby

Chef style/correctness tests can be performed with Foodcritic by issuing either

chef exec rake style:chef

Spec Testing

Unit testing is done by running Rspec examples.

chef exec rake spec

Integration Testing

To see a list of available test instances run:

chef exec kitchen list

To test specific instance run:

chef exec kitchen test INSTANCE_NAME