gitlab-org--gitlab-foss/spec/lib/gitlab/popen_spec.rb

46 lines
1,001 B
Ruby
Raw Normal View History

2013-02-26 15:53:46 -05:00
require 'spec_helper'
describe 'Gitlab::Popen', no_db: true do
let (:path) { Rails.root.join('tmp').to_s }
before do
@klass = Class.new(Object)
@klass.send(:include, Gitlab::Popen)
end
context 'zero status' do
before do
@output, @status = @klass.new.popen(%W(ls), path)
2013-02-26 15:53:46 -05:00
end
it { @status.should be_zero }
2013-02-27 01:24:12 -05:00
it { @output.should include('cache') }
2013-02-26 15:53:46 -05:00
end
context 'non-zero status' do
before do
@output, @status = @klass.new.popen(%W(cat NOTHING), path)
2013-02-26 15:53:46 -05:00
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
2013-02-26 15:53:46 -05:00
end