Write RSpec examples and generate coverage reports for Chef recipes!
Bugfixes:
Improvements:
knife-spec
have_state_attrs
for testing custom LWRP state attributesBreaking:
ChefSpec::ChefRunner
to ChefSpec::Runner
to better reflect what happens in Chef Core. Using ChefRunner
will throw deprecation errors for now and will be removed in a future release.ChefSpec::NoConversionError
. The following matchers have changed:
execute_command
=> run_execute
set_service_to_start_on_boot
=> enable_service
create_file_with_content
=> render_file
execute_(script)
=> run_(script)
execute_ruby_block
=> run_ruby_block
install_package_at_version
=> install_package().with(version: '')
*_python_pip
=> (removed - see "Packaging Custom LWRPs in the README")package
matcher would match on any kind of package and any kind of package action. However, some subclasses of the package resource do not support all actions. Each package provider now has it's own matcher with only the actions it supports. Prior specs that used the generic package
matcher will no longer match on subclasses - you must use the specific subclass matcher.file
matcher would match on file
, cookbook_file
, and template
. This is not ideal because it doesn't verify the correct message was sent. Now, file
, cookbook_file
, and template
matchers will only match resources of that type. For generic file checking, please use the new render_file
matcher.stub_command
macro.Runner#resources
converted from an Array to a Hash. This is to ensure that all resource actions are added (when multiple calls to run_action exist (#201)). This also drastically improves resource lookup times.Resource#actions
is no longer maniuplated. Instead, a new method Resource#performed_actions
now keeps track of the actions taken on a resource (as well as the phase in which they were taken), preserving the original state of the resource.Features:
render_file
action to replace create_file_with_content
. This matcher will render the contents of any file to a string and then optionally compare the result if given a with
chainable.with
chainable for matching specific resource attributes.inherits
)batch
resource matcherscookbook_file
resource matchersdeploy
resource matcherserl_call
resource matchersgit
resource matchershttp_request
resource matchersifconfig
resource matcherslink
resource matcherslog
resource matchersmdadm
resource matchersmount
resource matchers:immediate
and :delayed
notification matchersohai
resource matcherspowershell_script
matchers (Chef 11.6+)registry_key
matchersremote_directory
matchersroute
matcherssubversion
matchersstub_command
macro (formerly on ChefSpec::ChefRunner
) for stubbbing the results of shell commands. Because shell commands are evaluated by default, ChefSpec will raise an exception when encountering a shell command that has not been stubbed.stub_search
macro for easily stubbing search
calls. Like shell commands, ChefSpec will raise an exception when encountering a search
call that has not been stubbed.stub_data_bag
macro for easily stubbing data_bag
calls. Like shell commands, ChefSpec will raise an exception when encountering a data_bag
call that has not been stubbed.stub_data_bag_item
macro for easily stubbingdata_bag_item
calls. Like shell commands, ChefSpec will raise an exception when encountering a data_bag_item
call that has not been stubbed.stub_node
helper for quickly generating a node object from Fauxhai dataChefSpec::Runner#apply
command to mimic the behavior of chef-apply
(use with caution)ChefSpec::Runner
object with the Node objectchefspec/berkshelf
for easily integrating specs with Berkshelf (2 & 3).at_compile_time
and .at_converge_time
matchers for asserting which phase of the Chef run a resource should be runImprovements:
shared_examples
for easily testing defined custom matcherscookbook_path
from the calling specresource_collection
to identify resources instead of our own custom proxy