diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-26 22:53:46 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-26 22:53:46 +0200 |
commit | 2c5e4955c020eb8d5a28a48d6adc375c327523ac (patch) | |
tree | 07c690adf89069f4b6afaef9e4266a2ce9c0597b | |
parent | 9c252a60c195cb348c9776f40ca2c6b1f33723f9 (diff) | |
download | gitlab-ce-2c5e4955c020eb8d5a28a48d6adc375c327523ac.tar.gz |
specs for Gitlab::Popen
-rw-r--r-- | spec/lib/popen_spec.rb | 29 | ||||
-rw-r--r-- | spec/support/db_cleaner.rb | 8 |
2 files changed, 35 insertions, 2 deletions
diff --git a/spec/lib/popen_spec.rb b/spec/lib/popen_spec.rb new file mode 100644 index 00000000000..f5b3f94750c --- /dev/null +++ b/spec/lib/popen_spec.rb @@ -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 + diff --git a/spec/support/db_cleaner.rb b/spec/support/db_cleaner.rb index f1e072aa15f..8c9c74f14bd 100644 --- a/spec/support/db_cleaner.rb +++ b/spec/support/db_cleaner.rb @@ -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 |