specs for Gitlab::Popen
This commit is contained in:
parent
9c252a60c1
commit
2c5e4955c0
2 changed files with 35 additions and 2 deletions
29
spec/lib/popen_spec.rb
Normal file
29
spec/lib/popen_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
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('ls', path)
|
||||
end
|
||||
|
||||
it { @status.should be_zero }
|
||||
it { @output.should include('pids') }
|
||||
end
|
||||
|
||||
context 'non-zero status' do
|
||||
before do
|
||||
@output, @status = @klass.new.popen('cat NOTHING', path)
|
||||
end
|
||||
|
||||
it { @status.should == 1 }
|
||||
it { @output.should include('No such file or directory') }
|
||||
end
|
||||
end
|
||||
|
|
@ -9,10 +9,14 @@ RSpec.configure do |config|
|
|||
DatabaseCleaner.strategy = :transaction
|
||||
end
|
||||
|
||||
DatabaseCleaner.start
|
||||
unless example.metadata[:no_db]
|
||||
DatabaseCleaner.start
|
||||
end
|
||||
end
|
||||
|
||||
config.after do
|
||||
DatabaseCleaner.clean
|
||||
unless example.metadata[:no_db]
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue