Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update for chefspec 0.9.0

- Add include_recipe example
- Update node attr set code to be compatible with the upcoming chef 11 release
  • Loading branch information...
commit 58cf9226872f6817743c1785b91c5a09e18e94d7 1 parent c8c0e98
Jim Hopp authored
2  Gemfile
... ... @@ -1,4 +1,4 @@
1 1 # A sample Gemfile
2 2 source "http://rubygems.org"
3 3
4   -gem "chefspec", "~>0.8"
  4 +gem "chefspec", "~>0.9"
18 Gemfile.lock
... ... @@ -1,9 +1,9 @@
1 1 GEM
2 2 remote: http://rubygems.org/
3 3 specs:
4   - builder (3.1.3)
  4 + builder (3.1.4)
5 5 bunny (0.7.9)
6   - chef (10.14.2)
  6 + chef (10.16.2)
7 7 bunny (>= 0.6.0, < 0.8.0)
8 8 erubis
9 9 highline (>= 1.6.9)
@@ -21,12 +21,12 @@ GEM
21 21 treetop (~> 1.4.9)
22 22 uuidtools
23 23 yajl-ruby (~> 1.1)
24   - chefspec (0.8.0)
  24 + chefspec (0.9.0)
25 25 chef (>= 0.9.12)
26 26 erubis
27 27 minitest-chef-handler (~> 0.6.0)
28 28 rspec (~> 2.11.0)
29   - ci_reporter (1.7.2)
  29 + ci_reporter (1.7.3)
30 30 builder (>= 2.1.2)
31 31 diff-lcs (1.1.3)
32 32 erubis (2.7.0)
@@ -34,8 +34,8 @@ GEM
34 34 ipaddress (0.8.0)
35 35 json (1.6.1)
36 36 mime-types (1.19)
37   - minitest (3.4.0)
38   - minitest-chef-handler (0.6.1)
  37 + minitest (4.2.0)
  38 + minitest-chef-handler (0.6.3)
39 39 chef
40 40 ci_reporter
41 41 minitest
@@ -69,9 +69,9 @@ GEM
69 69 rspec-core (2.11.1)
70 70 rspec-expectations (2.11.3)
71 71 diff-lcs (~> 1.1.3)
72   - rspec-mocks (2.11.2)
  72 + rspec-mocks (2.11.3)
73 73 systemu (2.5.2)
74   - treetop (1.4.10)
  74 + treetop (1.4.12)
75 75 polyglot
76 76 polyglot (>= 0.3.1)
77 77 uuidtools (2.1.3)
@@ -81,4 +81,4 @@ PLATFORMS
81 81 ruby
82 82
83 83 DEPENDENCIES
84   - chefspec (~> 0.8)
  84 + chefspec (~> 0.9)
2  cookbooks/mytestcookbook/recipes/include_recipes.rb
... ... @@ -0,0 +1,2 @@
  1 +
  2 +include_recipe "mytestcookbook::included_recipe"
2  cookbooks/mytestcookbook/recipes/included_recipe.rb
... ... @@ -0,0 +1,2 @@
  1 +
  2 +log "this is an included recipe"
2  cookbooks/mytestcookbook/spec/attr_tests_spec.rb
@@ -9,7 +9,7 @@
9 9 end
10 10 it 'can set values for default attributes' do
11 11 runner = ChefSpec::ChefRunner.new do |node|
12   - node["mytestcookbook"] = { :attr_a => 'bar' }
  12 + node.set["mytestcookbook"] = { :attr_a => 'bar' }
13 13 end
14 14 runner.converge 'mytestcookbook::default'
15 15 runner.node.mytestcookbook.attr_a.should eq 'bar'
9 cookbooks/mytestcookbook/spec/include_recipe_spec.rb
... ... @@ -0,0 +1,9 @@
  1 +require 'bundler/setup'
  2 +require 'chefspec'
  3 +
  4 +describe 'include_recipe tests' do
  5 + let (:chef_run) { ChefSpec::ChefRunner.new.converge 'mytestcookbook::include_recipes' }
  6 + it 'includes another recipe' do
  7 + chef_run.should include_recipe 'mytestcookbook::included_recipe'
  8 + end
  9 +end
4 cookbooks/mytestcookbook/spec/lwrp_spec.rb
@@ -6,7 +6,7 @@
6 6 runner = ChefSpec::ChefRunner.new(:step_into => ['mytestcookbook_manage'])
7 7 }
8 8 let(:chef_run) {
9   - runner.node["mytestcookbook"] = { :cmd => 'echo "adios"' }
  9 + runner.node.set["mytestcookbook"] = { :cmd => 'echo "adios"' }
10 10 runner.converge 'mytestcookbook::lwrp'
11 11 }
12 12 it 'should install foo' do
@@ -14,7 +14,7 @@
14 14 end
15 15 it 'executes stuff' do
16 16 cmd = 'echo "hello!"'
17   - runner.node["mytestcookbook"] = { :cmd => cmd }
  17 + runner.node.set["mytestcookbook"] = { :cmd => cmd }
18 18 runner.converge 'mytestcookbook::lwrp'
19 19 runner.should execute_command cmd
20 20 end

0 comments on commit 58cf922

Please sign in to comment.
Something went wrong with that request. Please try again.