Tag Chefspec

Using Fake Cookbooks for Writing ChefSpec Tests for your Custom Chef Resources

A directory structure I've found quite useful for writing ChefSpec tests for custom resources, by creating a fake cookbook within the cookbook you're testing.

Chef 14 Upgrade: Custom Resource Properties are Silently Coerced to `Hash` if they are a `nil`

Finding out that a nil gets silently coerced to an empty Hash if given to a custom resource's property of type Hash.

Chef 14: ChefSpec Coverage Reporting Deprecation

Noting the deprecation of using ChefSpec::Coverage.start! when using Chef 14 and above.

Chef 14 Upgrade: Change in `ValidationFailed` error messages when setting `required` properties

The updated error message returned by a Chef ValidationFailed error, when you're specifying which properties are required on a custom resource.

Test-Driven Chef Cookbook Development Using ChefSpec (and a sprinkling of InSpec)

Using the example of deploying and running a Java JAR file as a way to show the lifecycle of a fully test-driven Chef cookbook.

Testing Chef's `ruby_block`s with ChefSpec

Testing implementation of a ruby_block in ChefSpec, to ensure that the code executes as expected

Chef 13 Upgrade: Lessons Learnt and Documented for Posterity

Notes on the main problems encountered when upgrading from Chef 12 to Chef 13, both with ChefSpec and Rubocop.

Chef 13 Upgrade: Rubocop Changes for Testing `render_file` with ChefSpec and a `with_content` Block

How to resolve the Parenthesize the param render_file Rubocop error when upgrading your cookbook to Chef 13.

Chef 13 Upgrade: Testing `ruby_block`s with ChefSpec

Replace your block.old_run_action with block.block.call to trigger ruby_blocks within ChefSpec 7 and Chef 13.

Getting around `Permission Denied` when running ChefSpec

How to handle getting an EACCES when trying to run ChefSpec on a recipe.

Testing `include_recipe`s with Chef and ChefSpec

How to best test include_recipes within your Chef recipes, as well as how to ensure that you aren't running any dependent recipes in your tests.