diff options
| author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-02-26 15:38:56 +0000 |
|---|---|---|
| committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-02-26 15:38:56 +0000 |
| commit | 63d0c0b93ba702340f9adf8e2772ecaddab635af (patch) | |
| tree | bfc5fc4be7383c61289927d693b8ca922566b110 /spec | |
| parent | 6c1af645668689f9d0e1b0693ea0db80b62d0bb3 (diff) | |
| parent | 36c2c354fc4829827960d202a070f8e7b87c9446 (diff) | |
| download | gitlab-ce-63d0c0b93ba702340f9adf8e2772ecaddab635af.tar.gz | |
Merge branch 'gitlab_popen_array' into 'master'
Change Gitlab::Popen to only accept arrays as commands
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/lib/gitlab/popen_spec.rb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/spec/lib/gitlab/popen_spec.rb b/spec/lib/gitlab/popen_spec.rb index 4791be41613..76d506eb3c0 100644 --- a/spec/lib/gitlab/popen_spec.rb +++ b/spec/lib/gitlab/popen_spec.rb @@ -10,7 +10,7 @@ describe 'Gitlab::Popen', no_db: true do context 'zero status' do before do - @output, @status = @klass.new.popen('ls', path) + @output, @status = @klass.new.popen(%W(ls), path) end it { @status.should be_zero } @@ -19,11 +19,27 @@ describe 'Gitlab::Popen', no_db: true do context 'non-zero status' do before do - @output, @status = @klass.new.popen('cat NOTHING', path) + @output, @status = @klass.new.popen(%W(cat NOTHING), path) end it { @status.should == 1 } it { @output.should include('No such file or directory') } end + + context 'unsafe string command' do + it 'raises an error when it gets called with a string argument' do + expect { @klass.new.popen('ls', path) }.to raise_error + 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 |
