Sha256: 001382a4fbf99bd67b6f5636641b194526997afcecef170fc77a898fdf0adbff

Contents?: true

Size: 919 Bytes

Versions: 5

Compression:

Stored size: 919 Bytes

Contents

require "spec_helper"

describe Boxes::Subprocess do
  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 if 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 if 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

  private

  def command
    File.expand_path("../support/subprocess_command.sh", __dir__).shellescape
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
boxes-3.7.0 spec/boxes/subprocess_spec.rb
boxes-3.6.1 spec/boxes/subprocess_spec.rb
boxes-3.6.0 spec/boxes/subprocess_spec.rb
boxes-3.5.0 spec/boxes/subprocess_spec.rb
boxes-3.4.0 spec/boxes/subprocess_spec.rb