summaryrefslogtreecommitdiff
path: root/spec/integration/solo
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2014-08-07 18:20:20 -0700
committerdanielsdeleo <dan@getchef.com>2014-08-10 09:40:36 -0700
commit674cc65dc68b9d5f0eaa36f2409c6c12becf2c11 (patch)
tree7c33437663b794c5cdbbd78eff5a77f0b83ead1f /spec/integration/solo
parente2a6b85f5b095f2350fa24f8e825fa22660fcbc7 (diff)
downloadchef-674cc65dc68b9d5f0eaa36f2409c6c12becf2c11.tar.gz
Convert Chef Zero helpers to instance methods
* Prefer instance methods to class methods for Chef Zero helpers. RSpec's design and feature set heavily favors using instance methods for test setup. This change will allow us to use let bindings and more naturally move common setup to shared contexts. * Temporarily copy ChefZero's RSpec features in-repo. master of Chef Zero is currently broken for unit testing. Copy the changes here for now so we can make progress. * Automatically generate a metadata file when using the "cookbook" helper function. This will be needed for a subsequent change that makes `name' required in metadata.
Diffstat (limited to 'spec/integration/solo')
-rw-r--r--spec/integration/solo/solo_spec.rb29
1 files changed, 18 insertions, 11 deletions
diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb
index 23ec8d0bad..b10ff379e2 100644
--- a/spec/integration/solo/solo_spec.rb
+++ b/spec/integration/solo/solo_spec.rb
@@ -6,14 +6,16 @@ require 'timeout'
require 'fileutils'
describe "chef-solo" do
- extend IntegrationSupport
+ include IntegrationSupport
include Chef::Mixin::ShellOut
let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..") }
when_the_repository "has a cookbook with a basic recipe" do
- file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
- file 'cookbooks/x/recipes/default.rb', 'puts "ITWORKS"'
+ before do
+ file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
+ file 'cookbooks/x/recipes/default.rb', 'puts "ITWORKS"'
+ end
it "should complete with success" do
file 'config/solo.rb', <<EOM
@@ -43,11 +45,13 @@ E
end
when_the_repository "has a cookbook with an undeclared dependency" do
- file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
- file 'cookbooks/x/recipes/default.rb', 'include_recipe "ancient::aliens"'
+ before do
+ file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
+ file 'cookbooks/x/recipes/default.rb', 'include_recipe "ancient::aliens"'
- file 'cookbooks/ancient/metadata.rb', 'version "1.0.0"'
- file 'cookbooks/ancient/recipes/aliens.rb', 'print "it was aliens"'
+ file 'cookbooks/ancient/metadata.rb', 'version "1.0.0"'
+ file 'cookbooks/ancient/recipes/aliens.rb', 'print "it was aliens"'
+ end
it "should exit with an error" do
file 'config/solo.rb', <<EOM
@@ -62,16 +66,19 @@ EOM
when_the_repository "has a cookbook with a recipe with sleep" do
- directory 'logs'
- file 'logs/runs.log', ''
- file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
- file 'cookbooks/x/recipes/default.rb', <<EOM
+ before do
+ directory 'logs'
+ file 'logs/runs.log', ''
+ file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
+ file 'cookbooks/x/recipes/default.rb', <<EOM
ruby_block "sleeping" do
block do
sleep 5
end
end
EOM
+ end
+
# Ruby 1.8.7 doesn't have Process.spawn :(
it "while running solo concurrently", :ruby_gte_19_only => true do
file 'config/solo.rb', <<EOM