2
2

More than 5 years have passed since last update.

Manual berkshelf caching on chefspec

Last updated at Posted at 2014-02-16

Chefspec 3.2.0 introduced berkshelf integration lately. However this will decrease the test speed as chefspec will setup and teardown berkshelf all the time.

Below is a snipped to similar chefspec#242 . But in addition, I removed the vendoring of the cookbook in development. Here is my rake task to do that build:

task :build do
  File.open("chefignore", "a").write("*aspnet_skeleton*")
  berksfile.install path: "vendor/cookbooks"
  FileUtils.rmdir "vendor/cookbooks/aspnet_skeleton"
end

This approach has several advantages: [1] chefspec doesn’t need to build the vendored directory everytime rspec is invoked, [2] you can run the test against the source code directory for a fast TDD feedback cycle, and [3] build and test phases for your CI pipeline can be separated.

Here’s how chefspec consumes the vendored cookbook_path and cookbook-in-development simultaenously:

RSpec.configure do |config|
  config.cookbook_path = %w(vendor/cookbooks ../)
end

Original post in http://amespinosa.wordpress.com/2014/02/16/manual-berkshelf-caching-on-chefspec/

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2