Sha256: 10725297760f0378b47275030a1592056ace4139e92bee19164dc707691a7ca7

Contents?: true

Size: 932 Bytes

Versions: 5

Compression:

Stored size: 932 Bytes

Contents

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)

require 'rspec'
require 'phare'

RSpec.configure do |config|
  config.before(:each) do
    # Disable all logging
    allow(Phare).to receive(:puts)
  end
end

RSpec::Matchers.define :be_able_to_run do
  match do |actual|
    actual.send(:should_run?) == true
  end
end

RSpec::Matchers.define :exit_with_code do |expected_code|
  actual = nil

  match do |block|
    begin
      block.call
    rescue SystemExit => e
      actual = e.status
    end

    actual && actual == expected_code
  end

  supports_block_expectations do
    true
  end

  failure_message do
    "expected block to call exit(#{expected_code}) but exit" +
      (actual.nil? ? ' not called' : "(#{actual}) was called")
  end

  failure_message_when_negated do
    "expected block not to call exit(#{expected_code})"
  end

  description do
    "expect block to call exit(#{expected_code})"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
phare-1.0.1 spec/spec_helper.rb
phare-1.0.0 spec/spec_helper.rb
phare-0.7.1 spec/spec_helper.rb
phare-0.7 spec/spec_helper.rb
phare-0.6 spec/spec_helper.rb