Skip to content

Latest commit

 

History

History
45 lines (27 loc) · 1.98 KB

TESTING.md

File metadata and controls

45 lines (27 loc) · 1.98 KB

Testing the Cookbook

This cookbook uses bundler, berkshelf, and strainer to isolate dependencies and run tests.

Tests are defined in Strainerfile, which in turn calls rubocop, knife, foodcritic and chefspec.

To run all of the tests with Strainer:

$ bundle install --path=.bundle
$ bundle exec strainer test -s Strainerfile

Or you may run the tests individually:

$ bundle install --path=.bundle
$ bundle exec rubocop
$ bundle exec knife cookbook test ibm-openstack-zvm-driver
$ bundle exec foodcritic -f any -t ~FC003 ./
$ bundle exec rspec spec

Rubocop

Rubocop is a static Ruby code analyzer, based on the community Ruby style guide. We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits.

Attribute Rules

Since there are slight style differences between the coding of attributes, recipes and metadata files there are specific .rubocop.yml files for each of:

Gemfile and metadata.rb attributes/*.rb recipes/.rubocop.yml spec/.rubocop.yml

Knife

knife cookbook test is used to check the cookbook's Ruby and ERB files for basic syntax errors.

Foodcritic

Foodcritic is a lint tool for Chef cookbooks. We ignore the following rules:

FC003 these cookbooks are not intended for Chef Solo.

Chefspec

ChefSpec is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers.