Commit 8016cefafe97d3a143cf21b270c110d357e46273
1 parent
0432bdf1
Exists in
spb-stable
and in
3 other branches
Make the Gitlab::Popen path argument optional
Showing
2 changed files
with
11 additions
and
1 deletions
Show diff stats
lib/gitlab/popen.rb
@@ -3,11 +3,12 @@ require 'open3' | @@ -3,11 +3,12 @@ require 'open3' | ||
3 | 3 | ||
4 | module Gitlab | 4 | module Gitlab |
5 | module Popen | 5 | module Popen |
6 | - def popen(cmd, path) | 6 | + def popen(cmd, path=nil) |
7 | unless cmd.is_a?(Array) | 7 | unless cmd.is_a?(Array) |
8 | raise "System commands must be given as an array of strings" | 8 | raise "System commands must be given as an array of strings" |
9 | end | 9 | end |
10 | 10 | ||
11 | + path ||= Dir.pwd | ||
11 | vars = { "PWD" => path } | 12 | vars = { "PWD" => path } |
12 | options = { chdir: path } | 13 | options = { chdir: path } |
13 | 14 |
spec/lib/gitlab/popen_spec.rb
@@ -32,5 +32,14 @@ describe 'Gitlab::Popen', no_db: true do | @@ -32,5 +32,14 @@ describe 'Gitlab::Popen', no_db: true do | ||
32 | end | 32 | end |
33 | end | 33 | end |
34 | 34 | ||
35 | + context 'without a directory argument' do | ||
36 | + before do | ||
37 | + @output, @status = @klass.new.popen(%W(ls)) | ||
38 | + end | ||
39 | + | ||
40 | + it { @status.should be_zero } | ||
41 | + it { @output.should include('spec') } | ||
42 | + end | ||
43 | + | ||
35 | end | 44 | end |
36 | 45 |