Sha256: 5c1dedbfc53fddb969dd5228fa8afa49cac8694e24f5311d579526b3b9de606c

Contents?: true

Size: 920 Bytes

Versions: 3

Compression:

Stored size: 920 Bytes

Contents

# frozen_string_literal: true

require "rspec"
require "clamp"
require "stringio"

RSpec.configure do |config|

  config.around(:each) do |example|
    begin
      example.run
    rescue SystemExit => e
      raise "Unexpected exit with status #{e.status}"
    end
  end

end

module OutputCapture

  def self.included(target)
    target.before do
      $stdout = @out = StringIO.new
      $stderr = @err = StringIO.new
    end

    target.after do
      $stdout = STDOUT
      $stderr = STDERR
    end
  end

  def stdout
    @out.string
  end

  def stderr
    @err.string
  end

end

module CommandFactory

  def given_command(name, &block)
    let(:command_class) do
      Class.new(Clamp::Command, &block)
    end
    let(:command) do
      command_class.new(name)
    end
  end

end

module SetEnv

  def set_env(name, value)
    if value
      ENV[name] = value
    else
      ENV.delete(name)
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clamp-1.3.2 spec/spec_helper.rb
clamp-1.3.1 spec/spec_helper.rb
clamp-1.3.0 spec/spec_helper.rb