@@ -676,8 +676,8 @@ def withenv_utf8(&block)
676
676
end
677
677
678
678
it "should walk the search PATH returning the first executable" do
679
- allow ( Puppet :: Util ) . to receive ( :get_env ) . with ( 'PATH' ) . and_return ( File . expand_path ( '/bin' ) )
680
- allow ( Puppet :: Util ) . to receive ( :get_env ) . with ( 'PATHEXT' ) . and_return ( nil )
679
+ allow ( ENV ) . to receive ( :[] ) . with ( 'PATH' ) . and_return ( File . expand_path ( '/bin' ) )
680
+ allow ( ENV ) . to receive ( :[] ) . with ( 'PATHEXT' ) . and_return ( nil )
681
681
682
682
expect ( Puppet ::Util . which ( 'foo' ) ) . to eq ( path )
683
683
end
@@ -693,8 +693,8 @@ def withenv_utf8(&block)
693
693
694
694
describe "when a file extension is specified" do
695
695
it "should walk each directory in PATH ignoring PATHEXT" do
696
- allow ( Puppet :: Util ) . to receive ( :get_env ) . with ( 'PATH' ) . and_return ( %w[ /bar /bin ] . map { |dir | File . expand_path ( dir ) } . join ( File ::PATH_SEPARATOR ) )
697
- allow ( Puppet :: Util ) . to receive ( :get_env ) . with ( 'PATHEXT' ) . and_return ( '.FOOBAR' )
696
+ allow ( ENV ) . to receive ( :[] ) . with ( 'PATH' ) . and_return ( %w[ /bar /bin ] . map { |dir | File . expand_path ( dir ) } . join ( File ::PATH_SEPARATOR ) )
697
+ allow ( ENV ) . to receive ( :[] ) . with ( 'PATHEXT' ) . and_return ( '.FOOBAR' )
698
698
699
699
expect ( FileTest ) . to receive ( :file? ) . with ( File . join ( File . expand_path ( '/bar' ) , 'foo.CMD' ) ) . and_return ( false )
700
700
@@ -705,8 +705,8 @@ def withenv_utf8(&block)
705
705
describe "when a file extension is not specified" do
706
706
it "should walk each extension in PATHEXT until an executable is found" do
707
707
bar = File . expand_path ( '/bar' )
708
- allow ( Puppet :: Util ) . to receive ( :get_env ) . with ( 'PATH' ) . and_return ( "#{ bar } #{ File ::PATH_SEPARATOR } #{ base } " )
709
- allow ( Puppet :: Util ) . to receive ( :get_env ) . with ( 'PATHEXT' ) . and_return ( ".EXE#{ File ::PATH_SEPARATOR } .CMD" )
708
+ allow ( ENV ) . to receive ( :[] ) . with ( 'PATH' ) . and_return ( "#{ bar } #{ File ::PATH_SEPARATOR } #{ base } " )
709
+ allow ( ENV ) . to receive ( :[] ) . with ( 'PATHEXT' ) . and_return ( ".EXE#{ File ::PATH_SEPARATOR } .CMD" )
710
710
711
711
expect ( FileTest ) . to receive ( :file? ) . ordered ( ) . with ( File . join ( bar , 'foo.EXE' ) ) . and_return ( false )
712
712
expect ( FileTest ) . to receive ( :file? ) . ordered ( ) . with ( File . join ( bar , 'foo.CMD' ) ) . and_return ( false )
@@ -717,8 +717,8 @@ def withenv_utf8(&block)
717
717
end
718
718
719
719
it "should walk the default extension path if the environment variable is not defined" do
720
- allow ( Puppet :: Util ) . to receive ( :get_env ) . with ( 'PATH' ) . and_return ( base )
721
- allow ( Puppet :: Util ) . to receive ( :get_env ) . with ( 'PATHEXT' ) . and_return ( nil )
720
+ allow ( ENV ) . to receive ( :[] ) . with ( 'PATH' ) . and_return ( base )
721
+ allow ( ENV ) . to receive ( :[] ) . with ( 'PATHEXT' ) . and_return ( nil )
722
722
723
723
%w[ .COM .EXE .BAT ] . each do |ext |
724
724
expect ( FileTest ) . to receive ( :file? ) . ordered ( ) . with ( File . join ( base , "foo#{ ext } " ) ) . and_return ( false )
@@ -729,8 +729,8 @@ def withenv_utf8(&block)
729
729
end
730
730
731
731
it "should fall back if no extension matches" do
732
- allow ( Puppet :: Util ) . to receive ( :get_env ) . with ( 'PATH' ) . and_return ( base )
733
- allow ( Puppet :: Util ) . to receive ( :get_env ) . with ( 'PATHEXT' ) . and_return ( ".EXE" )
732
+ allow ( ENV ) . to receive ( :[] ) . with ( 'PATH' ) . and_return ( base )
733
+ allow ( ENV ) . to receive ( :[] ) . with ( 'PATHEXT' ) . and_return ( ".EXE" )
734
734
735
735
allow ( FileTest ) . to receive ( :file? ) . with ( File . join ( base , 'foo.EXE' ) ) . and_return ( false )
736
736
allow ( FileTest ) . to receive ( :file? ) . with ( File . join ( base , 'foo' ) ) . and_return ( true )
0 commit comments