diff options
author | John Keiser <jkeiser@opscode.com> | 2013-12-05 14:22:19 -0800 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-12-06 13:50:10 -0800 |
commit | 5e87b84187e8d341fc83bdc90f5a1ce25c871610 (patch) | |
tree | 4d79c77f2b8131db9b3b971b8522e5d4d09b07cb /spec/integration/client | |
parent | d85df00ffbedfa440ea529d96a8dc9245fbe44ed (diff) | |
download | chef-5e87b84187e8d341fc83bdc90f5a1ce25c871610.tar.gz |
Add ability to run recipes directly from chef-client command line
Diffstat (limited to 'spec/integration/client')
-rw-r--r-- | spec/integration/client/client_spec.rb | 77 |
1 files changed, 75 insertions, 2 deletions
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index ffdded10e8..a114924666 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -101,14 +101,87 @@ EOM it "should complete with success even with a client key" do file 'config/client.rb', <<EOM local_mode true -client_key "#{path_to('mykey.pem')}" -cookbook_path "#{path_to('cookbooks')}" +client_key #{path_to('mykey.pem').inspect} +cookbook_path #{path_to('cookbooks').inspect} EOM chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..", "bin") result = shell_out("chef-client -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) result.error! end + + it "should run recipes specified directly on the command line" do + file 'config/client.rb', <<EOM +local_mode true +client_key #{path_to('mykey.pem').inspect} +cookbook_path #{path_to('cookbooks').inspect} +EOM + + file 'arbitrary.rb', <<EOM +file #{path_to('tempfile.txt').inspect} do + content '1' +end +EOM + + file 'arbitrary2.rb', <<EOM +file #{path_to('tempfile2.txt').inspect} do + content '2' +end +EOM + + chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..", "bin") + result = shell_out("chef-client -c \"#{path_to('config/client.rb')}\" #{path_to('arbitrary.rb')} #{path_to('arbitrary2.rb')}", :cwd => chef_dir) + result.error! + + IO.read(path_to('tempfile.txt')).should == '1' + IO.read(path_to('tempfile2.txt')).should == '2' + end + + it "should run recipes specified as relative paths directly on the command line" do + file 'config/client.rb', <<EOM +local_mode true +client_key #{path_to('mykey.pem').inspect} +cookbook_path #{path_to('cookbooks').inspect} +EOM + + file 'arbitrary.rb', <<EOM +file #{path_to('tempfile.txt').inspect} do + content '1' +end +EOM + + chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..", "bin") + result = shell_out("#{chef_dir}/chef-client -c \"#{path_to('config/client.rb')}\" arbitrary.rb", :cwd => path_to('')) + result.error! + + IO.read(path_to('tempfile.txt')).should == '1' + end + + it "should run recipes specified directly on the command line AFTER recipes in the run list" do + file 'config/client.rb', <<EOM +local_mode true +client_key #{path_to('mykey.pem').inspect} +cookbook_path #{path_to('cookbooks').inspect} +EOM + + file 'cookbooks/x/recipes/constant_definition.rb', <<EOM +class ::Blah + THECONSTANT = '1' +end +EOM + file 'arbitrary.rb', <<EOM +file #{path_to('tempfile.txt').inspect} do + content ::Blah::THECONSTANT +end +EOM + + chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..", "bin") + result = shell_out("#{chef_dir}/chef-client -c \"#{path_to('config/client.rb')}\" -o x::constant_definition arbitrary.rb", :cwd => path_to('')) + result.error! + + IO.read(path_to('tempfile.txt')).should == '1' + end + end it "should complete with success when passed the -z flag" do |