Commit 2c5e4955c020eb8d5a28a48d6adc375c327523ac
1 parent
9c252a60
Exists in
master
and in
4 other branches
specs for Gitlab::Popen
Showing
2 changed files
with
35 additions
and
2 deletions
Show diff stats
@@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe 'Gitlab::Popen', no_db: true do | ||
4 | + let (:path) { Rails.root.join('tmp').to_s } | ||
5 | + | ||
6 | + before do | ||
7 | + @klass = Class.new(Object) | ||
8 | + @klass.send(:include, Gitlab::Popen) | ||
9 | + end | ||
10 | + | ||
11 | + context 'zero status' do | ||
12 | + before do | ||
13 | + @output, @status = @klass.new.popen('ls', path) | ||
14 | + end | ||
15 | + | ||
16 | + it { @status.should be_zero } | ||
17 | + it { @output.should include('pids') } | ||
18 | + end | ||
19 | + | ||
20 | + context 'non-zero status' do | ||
21 | + before do | ||
22 | + @output, @status = @klass.new.popen('cat NOTHING', path) | ||
23 | + end | ||
24 | + | ||
25 | + it { @status.should == 1 } | ||
26 | + it { @output.should include('No such file or directory') } | ||
27 | + end | ||
28 | +end | ||
29 | + |
spec/support/db_cleaner.rb
@@ -9,10 +9,14 @@ RSpec.configure do |config| | @@ -9,10 +9,14 @@ RSpec.configure do |config| | ||
9 | DatabaseCleaner.strategy = :transaction | 9 | DatabaseCleaner.strategy = :transaction |
10 | end | 10 | end |
11 | 11 | ||
12 | - DatabaseCleaner.start | 12 | + unless example.metadata[:no_db] |
13 | + DatabaseCleaner.start | ||
14 | + end | ||
13 | end | 15 | end |
14 | 16 | ||
15 | config.after do | 17 | config.after do |
16 | - DatabaseCleaner.clean | 18 | + unless example.metadata[:no_db] |
19 | + DatabaseCleaner.clean | ||
20 | + end | ||
17 | end | 21 | end |
18 | end | 22 | end |