Sha256: beaa7e69ad0b94c12abbdc67b10c8fc220717aaff2d9ab5c5f5028c1ed2193f3

Contents?: true

Size: 560 Bytes

Versions: 5

Compression:

Stored size: 560 Bytes

Contents

# frozen_string_literal: true

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

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

    actual && actual == code
  end

  failure_message do |_block|
    "expected block to call exit(#{code}) but exit" +
      (actual ? "(#{actual}) was called" : " not called")
  end

  failure_message_when_negated do |_block|
    "expected block not to call exit(#{code})"
  end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kitabu-3.1.0 spec/support/exit_with_code.rb
kitabu-3.0.3 spec/support/exit_with_code.rb
kitabu-3.0.2 spec/support/exit_with_code.rb
kitabu-3.0.1 spec/support/exit_with_code.rb
kitabu-3.0.0 spec/support/exit_with_code.rb