specs for Gitlab::Popen

5-0-stable
Dmitriy Zaporozhets 2013-02-26 22:53:46 +02:00
parent 9c252a60c1
commit 2c5e4955c0
2 changed files with 35 additions and 2 deletions

29
spec/lib/popen_spec.rb Normal file
View 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

View File

@ -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