Commit 8016cefa authored by Jacob Vosmaer's avatar Jacob Vosmaer

Make the Gitlab::Popen path argument optional

parent 0432bdf1
...@@ -3,11 +3,12 @@ require 'open3' ...@@ -3,11 +3,12 @@ require 'open3'
module Gitlab module Gitlab
module Popen module Popen
def popen(cmd, path) def popen(cmd, path=nil)
unless cmd.is_a?(Array) unless cmd.is_a?(Array)
raise "System commands must be given as an array of strings" raise "System commands must be given as an array of strings"
end end
path ||= Dir.pwd
vars = { "PWD" => path } vars = { "PWD" => path }
options = { chdir: path } options = { chdir: path }
......
...@@ -32,5 +32,14 @@ describe 'Gitlab::Popen', no_db: true do ...@@ -32,5 +32,14 @@ describe 'Gitlab::Popen', no_db: true do
end end
end end
context 'without a directory argument' do
before do
@output, @status = @klass.new.popen(%W(ls))
end
it { @status.should be_zero }
it { @output.should include('spec') }
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment