Sha256: 66b77a9855fd887d9b770677cac451db4c2a688ec759550583606167944ca92f

Contents?: true

Size: 847 Bytes

Versions: 2

Compression:

Stored size: 847 Bytes

Contents

require 'spec_helper'

describe Boxes::Subprocess do
  let(:command) { "spec/support/subprocess_command.rb" }

  it 'runs a command and yields a block' do
    expect { |b| Boxes::Subprocess.run(command, &b) }.to yield_control
  end

  it 'runs a command and returns stdout' do
    total_stdout = ''
    Boxes::Subprocess.run(command) do |stdout, _stderr, _thread|
      total_stdout << stdout
    end

    expect(total_stdout).to eq "A happy output.\n"
  end

  it 'runs a command and returns stderr' do
    total_stderr = ''
    Boxes::Subprocess.run(command) do |_stdout, stderr, _thread|
      total_stderr << stderr
    end

    expect(total_stderr).to eq "An unhappy output.\n"
  end

  it 'returns a status code' do
    status = Boxes::Subprocess.run(command) { |_stdout, _stderr, _thread| }

    expect(status.exitstatus).to eq 5
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
boxes-2.5.0 spec/boxes/subprocess_spec.rb
boxes-2.4.0 spec/boxes/subprocess_spec.rb