diff options
author | Markus Roberts <Markus@reality.com> | 2010-11-04 13:53:23 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2010-11-12 15:02:00 +1100 |
commit | b15231df5842df2ea83b779b22e6756e51bc39d0 (patch) | |
tree | 34978db4a199ccca92e35c66e154851bc60fff27 /spec | |
parent | ea435a43dc97487d054271a9efb208f361408339 (diff) | |
download | puppet-b15231df5842df2ea83b779b22e6756e51bc39d0.tar.gz puppet-b15231df5842df2ea83b779b22e6756e51bc39d0.tar.xz puppet-b15231df5842df2ea83b779b22e6756e51bc39d0.zip |
Fix for #4299 -- Don't require which
We already had an internal implementation of which hiding under an assumed
name (Puppet::Util.binary); this commit calls it out of hiding and uses it
consisantly.
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/integration/ssl/certificate_authority_spec.rb | 4 | ||||
-rwxr-xr-x | spec/unit/provider/confine/exists_spec.rb | 19 | ||||
-rw-r--r-- | spec/unit/util/command_line_spec.rb | 4 |
3 files changed, 9 insertions, 18 deletions
diff --git a/spec/integration/ssl/certificate_authority_spec.rb b/spec/integration/ssl/certificate_authority_spec.rb index fca17b405..67ff6f215 100755 --- a/spec/integration/ssl/certificate_authority_spec.rb +++ b/spec/integration/ssl/certificate_authority_spec.rb @@ -121,9 +121,7 @@ describe Puppet::SSL::CertificateAuthority do it "should save valid certificates" do @ca.sign("luke.madstop.com") - ssl = %x{which openssl} - - unless ssl + unless ssl = Puppet::Util::which('openssl') pending "No ssl available" else ca_cert = Puppet[:cacert] diff --git a/spec/unit/provider/confine/exists_spec.rb b/spec/unit/provider/confine/exists_spec.rb index c3958e317..f039208b8 100755 --- a/spec/unit/provider/confine/exists_spec.rb +++ b/spec/unit/provider/confine/exists_spec.rb @@ -39,25 +39,18 @@ describe Puppet::Provider::Confine::Exists do describe "and the confine is for binaries" do before { @confine.stubs(:for_binary).returns true } - it "should use its 'binary' method to look up the full path of the file" do - @confine.expects(:binary).returns nil + it "should use its 'which' method to look up the full path of the file" do + @confine.expects(:which).returns nil @confine.pass?("/my/file") end - it "should return false if no binary can be found" do - @confine.expects(:binary).with("/my/file").returns nil + it "should return false if no executable can be found" do + @confine.expects(:which).with("/my/file").returns nil @confine.pass?("/my/file").should be_false end - it "should return true if the binary can be found and the file exists" do - @confine.expects(:binary).with("/my/file").returns "/my/file" - FileTest.expects(:exist?).with("/my/file").returns true - @confine.pass?("/my/file").should be_true - end - - it "should return false if the binary can be found but the file does not exist" do - @confine.expects(:binary).with("/my/file").returns "/my/file" - FileTest.expects(:exist?).with("/my/file").returns true + it "should return true if the executable can be found" do + @confine.expects(:which).with("/my/file").returns "/my/file" @confine.pass?("/my/file").should be_true end end diff --git a/spec/unit/util/command_line_spec.rb b/spec/unit/util/command_line_spec.rb index a83ad968d..7ba965249 100644 --- a/spec/unit/util/command_line_spec.rb +++ b/spec/unit/util/command_line_spec.rb @@ -86,7 +86,7 @@ describe Puppet::Util::CommandLine do describe "when the subcommand is not implemented" do it "should find and invoke an executable with a hyphenated name" do commandline = Puppet::Util::CommandLine.new("puppet", ['whatever', 'argument'], @tty) - Puppet::Util.expects(:binary).with('puppet-whatever').returns('/dev/null/puppet-whatever') + Puppet::Util.expects(:which).with('puppet-whatever').returns('/dev/null/puppet-whatever') commandline.expects(:system).with('/dev/null/puppet-whatever', 'argument') commandline.execute @@ -95,7 +95,7 @@ describe Puppet::Util::CommandLine do describe "and an external implementation cannot be found" do it "should abort and show the usage message" do commandline = Puppet::Util::CommandLine.new("puppet", ['whatever', 'argument'], @tty) - Puppet::Util.expects(:binary).with('puppet-whatever').returns(nil) + Puppet::Util.expects(:which).with('puppet-whatever').returns(nil) commandline.expects(:system).never commandline.expects(:usage_message).returns("the usage message") |