cookbook 'minitest-handler', '= 1.4.0'
minitest-handler
(30) Versions
1.4.0
-
Follow12
Installs and configures minitest-chef-handler
cookbook 'minitest-handler', '= 1.4.0', :supermarket
knife supermarket install minitest-handler
knife supermarket download minitest-handler
minitest-handler cookbook
License: Apache 2.0 <br />
Copyright: 2012 Opscode, Inc.<br/>
Author: Bryan McLellan btm@loftninjas.org<br/>
Author: Bryan W. Berry bryan.berry@gmail.com<br/>
Description
This cookbook utilizes the minitest-chef-handler project to facilitate
cookbook testing. By default, minitest-handler will collect all the
tests in your cookbook_path and run them.
minitest-chef-handler project: https://github.com/calavera/minitest-chef-handler<br/>
stable minitest-handler cookbook: http://community.opscode.com/cookbooks/minitest-handler<br/>
minitest-handler cookbook development: https://github.com/btm/minitest-handler-cookbook<br/>
Note: Version 0.1.8 deprecated use of
files/default/tests/minitest/*_test.rb
and the location of support
files. Test files should now be located in
files/default/test/*_test.rb
Note: Version 0.1.0 added a change that breaks backward compatibility. The minitest-handler now only loads<br/>
test files named "<recipe-name>_test.rb" rather than all test files in the path files/default/test/*_test.rb
If you have any helper libraries, they should match files/default/test/*helper*.rb
Attributes
-
node[:minitest][:gem_version]
- The version of the minitest gem to install and use.- Default: 3.0.1
-
node[:minitest][:chef_handler_gem_version]
- The version of the minitest-chef-handler gem to install and use.- Default: 1.0.3
-
node[:minitest][:chef_handler_gem_source]
- Alternate remote source for the minitest-chef-handler gem if not using RubyGems.org.(Ex http://mysource.com/gems')- Default: RubyGems.org
-
node[:minitest][:ci_reporter_gem_version]
- The version of the ci_reporter gem to install and use.- Default: 1.9.2
-
node[:minitest][:path]
- Location to store and find test files.- Default:
/var/chef/minitest
- Default:
-
node[:minitest][:recipes]
- The names of all recipes included during the chef run, whether by insertion to the run_list, inclusion through a role, or added withinclude_recipe
. If you only want tests for select recipes to run, override this value with the names of the recipes that you want tested.- Default: []
-
node[:minitest][:filter]
- Filter test names on a pattern (regex)- Default:
nil
- Example:
/apache2/
could be used to only run tests for recipes starting with apache2
- Default:
-
node[:minitest][:seed]
- Set random seed- Default:
nil
- Default:
-
node[:minitest][:ci_reports]
- Path to write out the result of each test in a JUnit-compatible XML file, parseable by many CI platforms- Default:
nil
- Default:
-
node[:minitest][:tests]
- Test files to run.- Default to
**/*_test.rb
- Default to
-
node[:minitest][:verbose]
- Display verbose output- Default: true
Usage
- Add
recipe[minitest-handler]
somewhere on your run_list, preferably last - Place tests in
files/default/test/
with the name your-recipe-name_test.rb (default recipe is named default_test.rb) - Put any helper functions you have in
files/default/test/spec_helper.rb
but minitest-handler will ensure that you have access to any file that matches the globfiles/test/*helper.rb
Examples
Traditional minitest
class TestApache2 < MiniTest::Chef::TestCase
def test_that_the_package_installed
case node[:platform]
when "ubuntu","debian"
assert system('apt-cache policy apache2 | grep Installed | grep -v none')
end
end
def test_that_the_service_is_running
assert system('/etc/init.d/apache2 status')
end
def test_that_the_service_is_enabled
assert File.exists?(Dir.glob("/etc/rc5.d/S*apache2").first)
end
end
Using minitest/spec
require 'minitest/spec'
describe_recipe 'ark::test' do
it "installed the unzip package" do
package("unzip").must_be_installed
end
it "dumps the correct files into place with correct owner and group" do
file("/usr/local/foo_dump/foo1.txt").must_have(:owner, "foobarbaz").and(:group, "foobarbaz")
end
end
For more detailed examples, see here
Testing this cookbook
This cookbook currently uses test-kitchen
along with the kitchen-vagrant.
All test are currently written using BATS,
which is essentially bash. Using BATS was done so that minitest-handler nor
minitest-chef-handler were used to test itself. For more examples of bats than
are in this cookbook, see the chef-rvm,
chef-ruby_build, and
chef-rbenv cookbooks.
NOTE A known limitation of using BATS is that the cookbook is not currently
tested on Windows machines. See https://github.com/btm/minitest-handler-cookbook/issues/45
for more of the background on this.
Releasing
This cookbook uses an 'even number' release strategy. The version number in master
will always be an odd number indicating development, and an even number will
be used when an official build is released.
Come release time here is the checklist:
* Ensure the metadata.rb
reflects the proper even numbered release
* Ensure there is a dated change log entry in CHANGELOG.md
* Commit all the changes
* Use stove to release (bundle exec stove
)
* Bump the version in metadata.rb to the next patch level odd number
Contributors
- David Petzel davidpetzel@gmail.com
- Reijo Pitkanen reijop@gmail.com
- Jean Mertz jean@mertz.fm
Changelog
1.4.0 (Jul 25, 2015)
- Add Chefspec tests for default recipe
- #67 - Perform more exact matching on which test files should be run
- #73 @josegonzalez - Support for an alternative approach to ignoring recipes
- #75 @heathsnow - Added ability to specify a source for minitest-chef-handler gem.
-
#76 @b-dean -
Bump the version of the minitest-chef-handler gem to
v1.1.0
1.3.2 (Jul 20, 2014)
-
#64 -
Fixed bug where test files were not dected properly detected under
chef-client
### 1.3.0 (Jul 25, 2014) -
#62 -
Increase default version of
chef_handler_gem
from 1.0.1 to 1.0.3. If for some reason you wish to avoid 1.0.3 ensure you set a value of 1.0.1 fornode[:minitest][:chef_handler_gem_version]
- #61 - Fix bug where Windows drive letters would cause errors when fetching cookbook files. Thanks matt-richardson!
-
#63 -
The
ci_reporter
gem version can now be controlled via the node attributenode[:minitest][:ci_reporter_gem_version]
, with a default of1.9.2
. Thanks jwitrick! - Upgraded versions of Chefspec, Foodcritic, and Rubocop
1.2.0 (Apr 23, 2014)
- Fixed bug where a test file saved in
files/default
(instead of one of the documented paths) would get processed. If you were previously relying on this unintended behaviour you will need to move your test files intofiles/default/test/
. A warning will be logged if any of these files are found to help you identify if this change affects you. - Efficiency Improvement. Previously all test files for a given cookbook would be downloaded to a temp directory regardless of if they were needed or not. Now only test files that are actually needed will be downloaded
-
#58 -
Expand use of
node[:minitest][:filter]
. Previously the filter would be applied to the execution of minitest, however files not matching the filter could still be downloaded but not executed. Now test file names not matching the filter won't be downloaded at all. - Rubocop cleanup
1.1.4 (Nov 14, 2013)
- Apply workaround for for build tools issues
- #57 - Fix for CHEF-3694
1.1.2 (Oct 29, 2013)
-
#55 -
Fix regression in 1.1.0 which was causing
undefined method 'scratch_dir'
1.1.0 (Oct 25, 2013)
- #47 - Control the version of minitest-chef-handler gem via node attribute
- #45 - Switch test-kitchen from lxc driver to vagrant driver, allowing tests to be run on Windows based host (Windows VMs still not supported)
- Moving long ruby block into a helper library to address FC014
1.0.0 (Oct 01, 2013)
- Check both paths in files
- Wrap the new to guard against chef solo per bryanwb's suggestion
- Force a download of testing files from chef server
- Fix test/support files detection when
cookbook_path
is an Array
v0.2.0 (May 05, 2013)
The path for placing your tests is now files/default/test/ however
this change is backwards compatible, the minitest-hander::default
recipe will also look in the old location
files/default/tests/minitest/
You should name your support files something that matches
files/default/test/helper.rb. The old support support/ location will
also be honored.
New Features:
* You can place minitest-handler anywhere in your run_list and it will
work. I like to use include_recipe
to add it.
* You can easily limit which tests are run by setting the array
node.set[:minitest][:recipes] with only those recipes that you want
tested
* minitest-handler now also will run test for any recipes added to the
run_list via include_recipe, environment, or roles.
Niceties:
* Added tests w/ test-kitchen 1.0, kitchen-lxc, and BATS
* huge code cleanup
v0.0.9 (Jun 14, 2012)
- add windows support tks to David Petzel
- add travis-ci integration
- change maintainer to Bryan W. Berry
v0.0.7 (Jun 04, 2012)
- Add better examples to the readme
- pass foodcritic
v0.0.6 (Jun 04, 2012)
- MINITEST-HANDLER-COOKBOOK-12 ensure minitest gem used and not the standard library in 1.9
- MINITEST-HANDLER-COOKBOOK-11 Add support for Chef-Solo
- Create the /var/chef/minitest directory if it doesn't already exist
v0.0.5 (Apr 13, 2012)
- Install the minitest-chef-handler gem instead of downloading from github directly
- Remove tests from cookbooks no longer in the run list
v0.0.4 (Apr 02, 2012)
Add examples/ top level directory (may not work)
Foodcritic Metric
1.4.0 failed this metric
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:5
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:6
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:9
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:11
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:12
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:13
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:14
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:16
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:18
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:20
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:21
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:22
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:26
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:27
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:28
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:24
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:31
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:41
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:63
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:64
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:67
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:68
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:69
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:89
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:111
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:119
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:121
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:131
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:141
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:4
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:10
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:16
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:26
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:37
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:38
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:39
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:40
FC031: Cookbook without metadata file: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/metadata.rb:1
FC045: Consider setting cookbook name in metadata: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/metadata.rb:1
1.4.0 failed this metric
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:5
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:6
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:9
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:11
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:12
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:13
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:14
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:16
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:18
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:20
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:21
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:22
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:26
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:27
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/attributes/default.rb:28
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:24
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:31
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:41
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:63
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:64
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:67
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:68
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:69
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:89
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:111
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:119
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:121
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:131
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/libraries/test_loader.rb:141
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:4
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:10
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:16
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:26
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:37
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:38
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:39
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/recipes/default.rb:40
FC031: Cookbook without metadata file: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/metadata.rb:1
FC045: Consider setting cookbook name in metadata: /tmp/cook/49e0b3403dd7fb8dbdfdd526/minitest-handler/metadata.rb:1