Skip to content

Instantly share code, notes, and snippets.

@mlafeldt
Created September 17, 2012 09:06
Show Gist options
  • Save mlafeldt/3736333 to your computer and use it in GitHub Desktop.
Save mlafeldt/3736333 to your computer and use it in GitHub Desktop.
ChefSpec cookbook dependencies

Works:

mkdir cookbooks
cd cookbooks/
git clone git://github.com/mlafeldt/ps2dev-cookbook.git ps2dev
git clone git://github.com/opscode-cookbooks/build-essential.git
git clone git://github.com/opscode-cookbooks/git.git
rspec .

The recipe ps2dev::default
  should install wget
  should execute toolchain-sudo.sh
  should delete directory /tmp/toolchain
  should create cookbook file /etc/profile.d/ps2dev.sh

Finished in 0.04716 seconds
4 examples, 0 failures

Doesn't work:

git clone git://github.com/mlafeldt/ps2dev-cookbook.git
cd ps2dev-cookbook/
rspec .

The recipe ps2dev::default
[2012-09-17T11:05:03+02:00] WARN: found a directory pulse-PKdhtXMmr18n in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory sni-qt_keepassx_2763-XomMBl in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory cookbooks in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory orbit-mlafeldt in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory pulse-2L9K88eMlGn7 in the cookbook path, but it contains no cookbook files. skipping.
  should install wget (FAILED - 1)
[2012-09-17T11:05:03+02:00] WARN: found a directory pulse-PKdhtXMmr18n in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory sni-qt_keepassx_2763-XomMBl in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory cookbooks in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory orbit-mlafeldt in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory pulse-2L9K88eMlGn7 in the cookbook path, but it contains no cookbook files. skipping.
  should execute toolchain-sudo.sh (FAILED - 2)
[2012-09-17T11:05:03+02:00] WARN: found a directory pulse-PKdhtXMmr18n in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory sni-qt_keepassx_2763-XomMBl in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory cookbooks in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory orbit-mlafeldt in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory pulse-2L9K88eMlGn7 in the cookbook path, but it contains no cookbook files. skipping.
  should delete directory /tmp/toolchain (FAILED - 3)
[2012-09-17T11:05:03+02:00] WARN: found a directory pulse-PKdhtXMmr18n in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory sni-qt_keepassx_2763-XomMBl in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory cookbooks in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory orbit-mlafeldt in the cookbook path, but it contains no cookbook files. skipping.
[2012-09-17T11:05:03+02:00] WARN: found a directory pulse-2L9K88eMlGn7 in the cookbook path, but it contains no cookbook files. skipping.
  should create cookbook file /etc/profile.d/ps2dev.sh (FAILED - 4)

Failures:

  1) The recipe ps2dev::default should install wget
     Failure/Error: let (:chef_run) { ChefSpec::ChefRunner.new.converge 'ps2dev::default' }
     Chef::Exceptions::CookbookNotFound:
       Cookbook ps2dev not found. If you're loading ps2dev from another cookbook, make sure you configure the dependency in your metadata
     # ./spec/default_spec.rb:4:in `block (2 levels) in <top (required)>'
     # ./spec/default_spec.rb:8:in `block (3 levels) in <top (required)>'

  2) The recipe ps2dev::default should execute toolchain-sudo.sh
     Failure/Error: let (:chef_run) { ChefSpec::ChefRunner.new.converge 'ps2dev::default' }
     Chef::Exceptions::CookbookNotFound:
       Cookbook ps2dev not found. If you're loading ps2dev from another cookbook, make sure you configure the dependency in your metadata
     # ./spec/default_spec.rb:4:in `block (2 levels) in <top (required)>'
     # ./spec/default_spec.rb:13:in `block (2 levels) in <top (required)>'

  3) The recipe ps2dev::default should delete directory /tmp/toolchain
     Failure/Error: let (:chef_run) { ChefSpec::ChefRunner.new.converge 'ps2dev::default' }
     Chef::Exceptions::CookbookNotFound:
       Cookbook ps2dev not found. If you're loading ps2dev from another cookbook, make sure you configure the dependency in your metadata
     # ./spec/default_spec.rb:4:in `block (2 levels) in <top (required)>'
     # ./spec/default_spec.rb:17:in `block (2 levels) in <top (required)>'

  4) The recipe ps2dev::default should create cookbook file /etc/profile.d/ps2dev.sh
     Failure/Error: let (:chef_run) { ChefSpec::ChefRunner.new.converge 'ps2dev::default' }
     Chef::Exceptions::CookbookNotFound:
       Cookbook ps2dev not found. If you're loading ps2dev from another cookbook, make sure you configure the dependency in your metadata
     # ./spec/default_spec.rb:4:in `block (2 levels) in <top (required)>'
     # ./spec/default_spec.rb:21:in `block (2 levels) in <top (required)>'

Finished in 0.01191 seconds
4 examples, 4 failures

Failed examples:

rspec ./spec/default_spec.rb:7 # The recipe ps2dev::default should install wget
rspec ./spec/default_spec.rb:12 # The recipe ps2dev::default should execute toolchain-sudo.sh
rspec ./spec/default_spec.rb:16 # The recipe ps2dev::default should delete directory /tmp/toolchain
rspec ./spec/default_spec.rb:20 # The recipe ps2dev::default should create cookbook file /etc/profile.d/ps2dev.sh
@mlafeldt
Copy link
Author

Thanks!

I ended up using Berkshelf (mlafeldt/ps2dev-cookbook#1) and even managed to run the tests with Travis (http://travis-ci.org/#!/mlafeldt/ps2dev-cookbook/builds/2477269). :)

Now I have everything I need to run (ChefSpec) tests for a cookbook that has its own git repo. And the repo's name doesn't matter either.

@mlafeldt
Copy link
Author

Hey @acrmp,

To work around Berkshelf's dependencies (Ruby >= 1.9.1 and Gecode), I wrote a simple script that does all I need for ChefSpec testing: https://github.com/mlafeldt/ps2dev-cookbook/blob/no-berkshelf/script/prepare-cookbooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment