summaryrefslogtreecommitdiff
path: root/spec/integration
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-12-09 11:54:53 -0800
committerJohn Keiser <john@johnkeiser.com>2015-12-09 13:02:18 -0800
commit010392858c2a3a036578b681085704ed1971ab21 (patch)
tree753775621a9f4a395aaa2c8fde8af5e4444f9c99 /spec/integration
parent7159ea473ce08c0483e9597af5b4d2ef1996dc36 (diff)
downloadchef-010392858c2a3a036578b681085704ed1971ab21.tar.gz
Don't activate cheffish and chef-provisioning until its DSL is usedjk/lazy-activation
Diffstat (limited to 'spec/integration')
-rw-r--r--spec/integration/client/client_spec.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index 41645adb9e..5e72a94065 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -340,6 +340,49 @@ EOM
end
end
+ when_the_repository "has a cookbook that uses cheffish resources" do
+ before do
+ file 'cookbooks/x/recipes/default.rb', <<-EOM
+ raise "Cheffish was loaded before we used any cheffish things!" if defined?(Cheffish::VERSION)
+ ran_block = false
+ got_server = with_chef_server 'https://blah.com' do
+ ran_block = true
+ run_context.cheffish.current_chef_server
+ end
+ raise "with_chef_server block was not run!" if !ran_block
+ raise "Cheffish was not loaded when we did cheffish things!" if !defined?(Cheffish::VERSION)
+ raise "current_chef_server did not return its value!" if got_server[:chef_server_url] != 'https://blah.com'
+ EOM
+ file 'config/client.rb', <<-EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ EOM
+ end
+
+ it "the cheffish DSL is loaded lazily" do
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ expect(command.exitstatus).to eql(0)
+ end
+ end
+
+ when_the_repository "has a cookbook that uses chef-provisioning resources" do
+ before do
+ file 'cookbooks/x/recipes/default.rb', <<-EOM
+ with_driver 'blah'
+ EOM
+ file 'config/client.rb', <<-EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ EOM
+ end
+
+ it "the cheffish DSL tries to load but fails (because chef-provisioning is not there)" do
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
+ expect(command.exitstatus).to eql(1)
+ expect(command.stdout).to match(/cannot load such file -- chef\/provisioning/)
+ end
+ end
+
when_the_repository "has a cookbook that generates deprecation warnings" do
before do
file 'cookbooks/x/recipes/default.rb', <<-EOM