Breaking:
- Renamed
ChefSpec::ChefRunnertoChefSpec::Runnerto better reflect what happens in Chef Core. UsingChefRunnerwill throw deprecation errors for now and will be removed in a future release. - Removed MiniTest Chef Handler examples/matchers
- No longer load default cookbook paths:
- vendor/cookbooks
- test/cookbooks
- test/integration (test kitchen)
- spec/cookbooks
- Resource matchers all follow the pattern "(action)_(resource_name)". ChefSpec will warn you of these deprecations in 3.0. They will be removed in 4.0. However, some resources cannot be automatically converted - these resources will raise a deprecation exception of
ChefSpec::NoConversionError. The following matchers have changed:execute_command=>run_executeset_service_to_start_on_boot=>enable_servicecreate_file_with_content=>render_fileexecute_(script)=>run_(script)execute_ruby_block=>run_ruby_blockinstall_package_at_version=>install_package().with(version: '')*_python_pip=> (removed - see "Packaging Custom LWRPs in the README")
- Remove dependency on Erubis
- Remove dependency on MiniTest Chef Handler
- Remove development dependency on Cucumber
- Remove development dependency on i18n
- Remove development dependency on simplecov
- Separate package matchers. In prior versions of ChefSpec, the
packagematcher 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 genericpackagematcher will no longer match on subclasses - you must use the specific subclass matcher. - Separate file/cookbook_file/template matchers. In prior versions of ChefSpec, the
filematcher would match onfile,cookbook_file, andtemplate. This is not ideal because it doesn't verify the correct message was sent. Now,file,cookbook_file, andtemplatematchers will only match resources of that type. For generic file checking, please use the newrender_filematcher. - Guards are now evaluated by default. If a shell guard is executed, it must first be stubbed with the
stub_commandmacro. Runner#resourcesconverted 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#actionsis no longer maniuplated. Instead, a new methodResource#performed_actionsnow 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:
- Added a new
render_fileaction to replacecreate_file_with_content. This matcher will render the contents of any file to a string and then optionally compare the result if given awithchainable. - All resources now accept a
withchainable for matching specific resource attributes. - Windows attributes are now testable on non-Windows systems (like
inherits) - Added
batchresource matchers - Added
cookbook_fileresource matchers - Added
deployresource matchers - Added
erl_callresource matchers - Added
gitresource matchers - Added
http_requestresource matchers - Added
ifconfigresource matchers - Normalized
linkresource matchers - Added
logresource matchers - Added
mdadmresource matchers - Added
mountresource matchers - Added
:immediateand:delayednotification matchers - Added
ohairesource matchers - Added
powershell_scriptmatchers (Chef 11.6+) - Added
registry_keymatchers - Added
remote_directorymatchers - Added
routematchers - Added
subversionmatchers - Added
stub_commandmacro (formerly onChefSpec::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. - Added
stub_searchmacro for easily stubbingsearchcalls. Like shell commands, ChefSpec will raise an exception when encountering asearchcall that has not been stubbed. - Added
stub_data_bagmacro for easily stubbingdata_bagcalls. Like shell commands, ChefSpec will raise an exception when encountering adata_bagcall that has not been stubbed. - Added
stub_data_bag_itemmacro for easily stubbingdata_bag_itemcalls. Like shell commands, ChefSpec will raise an exception when encountering adata_bag_itemcall that has not been stubbed. - Added
stub_nodehelper for quickly generating a node object from Fauxhai data - Added
ChefSpec::Runner#applycommand to mimic the behavior ofchef-apply(use with caution) - Share the
ChefSpec::Runnerobject with the Node object - Add
chefspec/berkshelffor easily integrating specs with Berkshelf (2 & 3) - Add
.at_compile_timeand.at_converge_timematchers for asserting which phase of the Chef run a resource should be run
Improvements:
- Move to inline documentation (Yard)
- Implement InProcess Aruba testing for ultra-fast tests
- Create "examples" directory for testing and demonstration
- Unified all failure_messages_for_should
- Use
shared_examplesfor easily testing defined custom matchers - Infer the
cookbook_pathfrom the calling spec - Directly set node attributes with Fauxhai (formerly this was an O(n) operation)
- Refactored ExpectExpectation to work without stubbing
- Use Chef's
resource_collectionto identify resources instead of our own custom proxy