Breaking:
- Renamed
ChefSpec::ChefRunner
toChefSpec::Runner
to better reflect what happens in Chef Core. UsingChefRunner
will 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_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")
- 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
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 genericpackage
matcher 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
file
matcher would match onfile
,cookbook_file
, andtemplate
. This is not ideal because it doesn't verify the correct message was sent. Now,file
,cookbook_file
, andtemplate
matchers will only match resources of that type. For generic file checking, please use the newrender_file
matcher. - Guards are now evaluated by default. If a shell guard is executed, it must first be stubbed with the
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 methodResource#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:
- Added a new
render_file
action 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 awith
chainable. - All resources now accept a
with
chainable for matching specific resource attributes. - Windows attributes are now testable on non-Windows systems (like
inherits
) - Added
batch
resource matchers - Added
cookbook_file
resource matchers - Added
deploy
resource matchers - Added
erl_call
resource matchers - Added
git
resource matchers - Added
http_request
resource matchers - Added
ifconfig
resource matchers - Normalized
link
resource matchers - Added
log
resource matchers - Added
mdadm
resource matchers - Added
mount
resource matchers - Added
:immediate
and:delayed
notification matchers - Added
ohai
resource matchers - Added
powershell_script
matchers (Chef 11.6+) - Added
registry_key
matchers - Added
remote_directory
matchers - Added
route
matchers - Added
subversion
matchers - Added
stub_command
macro (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_search
macro for easily stubbingsearch
calls. Like shell commands, ChefSpec will raise an exception when encountering asearch
call that has not been stubbed. - Added
stub_data_bag
macro for easily stubbingdata_bag
calls. Like shell commands, ChefSpec will raise an exception when encountering adata_bag
call that has not been stubbed. - Added
stub_data_bag_item
macro for easily stubbingdata_bag_item
calls. Like shell commands, ChefSpec will raise an exception when encountering adata_bag_item
call that has not been stubbed. - Added
stub_node
helper for quickly generating a node object from Fauxhai data - Added
ChefSpec::Runner#apply
command to mimic the behavior ofchef-apply
(use with caution) - Share the
ChefSpec::Runner
object with the Node object - Add
chefspec/berkshelf
for easily integrating specs with Berkshelf (2 & 3) - Add
.at_compile_time
and.at_converge_time
matchers 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_examples
for easily testing defined custom matchers - Infer the
cookbook_path
from 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_collection
to identify resources instead of our own custom proxy