Skip to content
Browse files

Put the supplemental path before the regular path

  • Loading branch information...
1 parent c788e5a commit eac6c949b59e0602668334b49fdf05894b3c82c9 @jyurek jyurek committed
Showing with 12 additions and 6 deletions.
  1. +1 −1 lib/cocaine/command_line.rb
  2. +11 −5 spec/cocaine/command_line_spec.rb
View
2 lib/cocaine/command_line.rb
@@ -12,7 +12,7 @@ def path
def path=(supplemental_path)
@supplemental_path = supplemental_path
@supplemental_environment ||= {}
- @supplemental_environment['PATH'] = [ENV['PATH'], *supplemental_path].join(File::PATH_SEPARATOR)
+ @supplemental_environment['PATH'] = [*supplemental_path, ENV['PATH']].join(File::PATH_SEPARATOR)
end
def posix_spawn_available?
View
16 spec/cocaine/command_line_spec.rb
@@ -12,11 +12,17 @@
end
it "specifies the $PATH where the command can be found" do
- Cocaine::CommandLine.path = "/path/to/command/dir"
- cmd = Cocaine::CommandLine.new("ruby", "-e 'puts ENV[%{PATH}]'")
- cmd.command.should == "ruby -e 'puts ENV[%{PATH}]'"
- output = cmd.run
- output.should match(%r{/path/to/command/dir})
+ saved_path = ENV['PATH']
+ begin
+ ENV['PATH'] = "/the/environment/path:/other/bin"
+ Cocaine::CommandLine.path = "/path/to/command/dir"
+ cmd = Cocaine::CommandLine.new("echo", "$PATH")
+ cmd.command.should == "echo $PATH"
+ output = cmd.run
+ output.should match(%r{/path/to/command/dir:/the/environment/path:/other/bin})
+ ensure
+ ENV['PATH'] = saved_path
+ end
end
it "specifies more than one path where the command can be found" do

0 comments on commit eac6c94

Please sign in to comment.
Something went wrong with that request. Please try again.