Permalink
Browse files

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...
1 parent c8c0e98 commit 58cf9226872f6817743c1785b91c5a09e18e94d7 @jimhopp committed Nov 12, 2012
View
2 Gemfile
@@ -1,4 +1,4 @@
# A sample Gemfile
source "http://rubygems.org"
-gem "chefspec", "~>0.8"
+gem "chefspec", "~>0.9"
View
18 Gemfile.lock
@@ -1,9 +1,9 @@
GEM
remote: http://rubygems.org/
specs:
- builder (3.1.3)
+ builder (3.1.4)
bunny (0.7.9)
- chef (10.14.2)
+ chef (10.16.2)
bunny (>= 0.6.0, < 0.8.0)
erubis
highline (>= 1.6.9)
@@ -21,21 +21,21 @@ GEM
treetop (~> 1.4.9)
uuidtools
yajl-ruby (~> 1.1)
- chefspec (0.8.0)
+ chefspec (0.9.0)
chef (>= 0.9.12)
erubis
minitest-chef-handler (~> 0.6.0)
rspec (~> 2.11.0)
- ci_reporter (1.7.2)
+ ci_reporter (1.7.3)
builder (>= 2.1.2)
diff-lcs (1.1.3)
erubis (2.7.0)
highline (1.6.15)
ipaddress (0.8.0)
json (1.6.1)
mime-types (1.19)
- minitest (3.4.0)
- minitest-chef-handler (0.6.1)
+ minitest (4.2.0)
+ minitest-chef-handler (0.6.3)
chef
ci_reporter
minitest
@@ -69,9 +69,9 @@ GEM
rspec-core (2.11.1)
rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
- rspec-mocks (2.11.2)
+ rspec-mocks (2.11.3)
systemu (2.5.2)
- treetop (1.4.10)
+ treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
uuidtools (2.1.3)
@@ -81,4 +81,4 @@ PLATFORMS
ruby
DEPENDENCIES
- chefspec (~> 0.8)
+ chefspec (~> 0.9)
View
2 cookbooks/mytestcookbook/recipes/include_recipes.rb
@@ -0,0 +1,2 @@
+
+include_recipe "mytestcookbook::included_recipe"
View
2 cookbooks/mytestcookbook/recipes/included_recipe.rb
@@ -0,0 +1,2 @@
+
+log "this is an included recipe"
View
2 cookbooks/mytestcookbook/spec/attr_tests_spec.rb
@@ -9,7 +9,7 @@
end
it 'can set values for default attributes' do
runner = ChefSpec::ChefRunner.new do |node|
- node["mytestcookbook"] = { :attr_a => 'bar' }
+ node.set["mytestcookbook"] = { :attr_a => 'bar' }
end
runner.converge 'mytestcookbook::default'
runner.node.mytestcookbook.attr_a.should eq 'bar'
View
9 cookbooks/mytestcookbook/spec/include_recipe_spec.rb
@@ -0,0 +1,9 @@
+require 'bundler/setup'
+require 'chefspec'
+
+describe 'include_recipe tests' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'mytestcookbook::include_recipes' }
+ it 'includes another recipe' do
+ chef_run.should include_recipe 'mytestcookbook::included_recipe'
+ end
+end
View
4 cookbooks/mytestcookbook/spec/lwrp_spec.rb
@@ -6,15 +6,15 @@
runner = ChefSpec::ChefRunner.new(:step_into => ['mytestcookbook_manage'])
}
let(:chef_run) {
- runner.node["mytestcookbook"] = { :cmd => 'echo "adios"' }
+ runner.node.set["mytestcookbook"] = { :cmd => 'echo "adios"' }
runner.converge 'mytestcookbook::lwrp'
}
it 'should install foo' do
chef_run.should install_package 'foo'
end
it 'executes stuff' do
cmd = 'echo "hello!"'
- runner.node["mytestcookbook"] = { :cmd => cmd }
+ runner.node.set["mytestcookbook"] = { :cmd => cmd }
runner.converge 'mytestcookbook::lwrp'
runner.should execute_command cmd
end

0 comments on commit 58cf922

Please sign in to comment.