From 2c5e4955c020eb8d5a28a48d6adc375c327523ac Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 26 Feb 2013 22:53:46 +0200 Subject: [PATCH] specs for Gitlab::Popen --- spec/lib/popen_spec.rb | 29 +++++++++++++++++++++++++++++ spec/support/db_cleaner.rb | 8 ++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 spec/lib/popen_spec.rb diff --git a/spec/lib/popen_spec.rb b/spec/lib/popen_spec.rb new file mode 100644 index 0000000..f5b3f94 --- /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 f1e072a..8c9c74f 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 -- libgit2 0.21.2