The goal behind cookbook rake tasks is to remove the duplication of tasks / tools that exist between multiple cookbooks.
This gem contains common rake tasks for:
- Checking the style of the cookbook (i.e. Rubocop and FoodCritic)
- Testing the cookbook (i.e. RSpec, ChefSpec, Test Kitchen)
Add this line to your application's Gemfile:
gem 'cookbook-raketasks'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cookbook-raketasks
If you want to add the style tasks to your cookbook.
- Create a
Rakefile
- Edit the
Rakefile
- Add the following require
require 'cookbook/raketasks/style'
This should give you the following tasks:
rake style # Run all style checks
rake style:chef # Lint Chef cookbooks
rake style:ruby # Run Ruby style checks (Rubocop)
rake style:ruby:auto_correct # Auto-correct RuboCop offenses
If you want to add the spec tasks to your cookbook:
- Create a Rakefile
- Edit the
Rakefile
- Add the following require:
require 'cookbook/raketasks/spec'
The should give you the following tasks:
rake spec # Run all specs
rake spec:integration # Run Test Kitchen with Vagrant
rake spec:unit # Run ChefSpec examples
If you want all of the tasks you can simply require the entire gem:
require 'cookbook/raketasks'
- Fork it ( https://github.com/burtlo/cookbook-raketasks/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request