Skip to content

Commit

Permalink
Fix cookbook_site_share tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmink committed Jun 26, 2014
1 parent 1921416 commit f6ad81f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 1 addition & 3 deletions lib/chef/knife/cookbook_site_share.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class Chef
class Knife
class CookbookSiteShare < Knife

include Chef::Mixin::ShellOut

deps do
require 'chef/cookbook_loader'
require 'chef/cookbook_uploader'
Expand Down Expand Up @@ -59,7 +57,7 @@ def run
begin
Chef::Log.debug("Temp cookbook directory is #{tmp_cookbook_dir.inspect}")
ui.info("Making tarball #{cookbook_name}.tgz")
shell_out!("tar -czf #{cookbook_name}.tgz #{cookbook_name}", :cwd => tmp_cookbook_dir)
Chef::Mixin::ShellOut::shell_out!("tar -czf #{cookbook_name}.tgz #{cookbook_name}", :cwd => tmp_cookbook_dir)
rescue => e
ui.error("Error making tarball #{cookbook_name}.tgz: #{e.message}. Increase log verbosity (-VV) for more information.")
Chef::Log.debug("\n#{e.backtrace.join("\n")}")
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/knife/cookbook_site_share_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@cookbook_uploader.stub(:validate_cookbooks).and_return(true)
Chef::CookbookSiteStreamingUploader.stub(:create_build_dir).and_return(Dir.mktmpdir)

Chef::Mixin::Command.stub(:run_command).and_return(true)
Chef::Mixin::ShellOut.stub(:shell_out!).and_return(true)
@stdout = StringIO.new
@knife.ui.stub(:stdout).and_return(@stdout)
end
Expand Down Expand Up @@ -76,14 +76,14 @@
end

it 'should make a tarball of the cookbook' do
Chef::Mixin::Command.should_receive(:run_command) { |args|
args[:command].should match /tar -czf/
}
Chef::Mixin::ShellOut.should_receive(:shell_out!) do |args|
args.should match /tar -czf/
end
@knife.run
end

it 'should exit and log to error when the tarball creation fails' do
Chef::Mixin::Command.stub(:run_command).and_raise(Chef::Exceptions::Exec)
Chef::Mixin::ShellOut.stub(:shell_out!).and_raise(Chef::Exceptions::Exec)
@knife.ui.should_receive(:error)
lambda { @knife.run }.should raise_error(SystemExit)
end
Expand Down

0 comments on commit f6ad81f

Please sign in to comment.