summaryrefslogtreecommitdiff
path: root/spec/lib/popen_spec.rb
blob: f5b3f94750cbc4b5b9bff79ef00acb85a50ea7b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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