cookbook 'example_resources', '= 1.0.5'
example_resources (13) Versions 1.0.5 Follow0
Provider cookbook that defines an example Chef resource. Integration tests in InSpec.
cookbook 'example_resources', '= 1.0.5', :supermarket
knife supermarket install example_resources
knife supermarket download example_resources
example_resources
This is a resource cookbook that demonstrates how to use InSpec for integration testing.
The purpose of this cookbook is to illustrate the relationship between a cookbook that defines a new Chef resource, and another cookbook that consumes it.
This is a simple resource cookbook that defines a Chef resource. I wrote another cookbook called example, which consumes the resource defined here.
To test
- Install bundled gems using Bundler in context of ChefDK
- Converge in context of Bundler and ChefDK
- Verify in context of Bundler and ChefDK
$ chef exec bundle install $ chef exec bundle exec kitchen converge $ chef exec bundle exec kitchen verify
Gemfile
Currently ChefDK provides Test Kitchen 1.5.0 which doesn't play nice with InSpec.
Note how I lock gem versions using the Gemfile. Run your tests in the context of these Gemfile
locks, otherwise you will likely see problems [at the time of this writing].
This is because ChefDK does a shim thing and locks Test Kitchen to 1.5.0, so I use a Gemfile to lock to Test Kitchen 1.6.0.
The ChefDK shim looks like this for ChefDK 0.15.2 on OS X:
$ cat /opt/chefdk/bin/kitchen #!/opt/chefdk/embedded/bin/ruby #--APP_BUNDLER_BINSTUB_FORMAT_VERSION=1-- ENV["GEM_HOME"] = ENV["GEM_PATH"] = nil unless ENV["APPBUNDLER_ALLOW_RVM"] == "true" gem "chef-config", "= 12.7.2" gem "mixlib-config", "= 2.2.1" gem "mixlib-shellout", "= 2.2.6" gem "mixlib-install", "= 0.7.1" gem "net-scp", "= 1.2.1" gem "net-ssh", "= 3.0.2" gem "safe_yaml", "= 1.0.4" gem "thor", "= 0.19.1" gem "test-kitchen", "= 1.5.0" spec = Gem::Specification.find_by_name("test-kitchen", "= 1.5.0") bin_file = spec.bin_file("kitchen") Kernel.load(bin_file)
Dependent cookbooks
This cookbook has no specified dependencies.
Contingent cookbooks
Changelog
This file tracks and describes changes to example_resources
.
This project adheres to semantic versioning 2.0.
v1.0.3 (2016-03-19)
- Minor updates
v1.0.2 (2016-03-19)
- Improve metadata for Supermarket
- Increase detail in readme
- Add license
- Point to Supermarket instead of GitHub
v1.0.1 (2016-03-18)
- Correct spelling of InSpec
v1.0.0 (2016-03-17)
- Refactor name from
example_resource_cookbook
toexample_resources
v0.1.0 (2016-03-16)
- Creates
example_resource
- Creates test cookbook
- Supports Centos
Foodcritic Metric
1.0.5 passed this metric
1.0.5 passed this metric