Sha256: 49d07e2dde32836534213e27a5f0781018e03a960b6ab783c2657dcb5111ca19

Contents?: true

Size: 517 Bytes

Versions: 7

Compression:

Stored size: 517 Bytes

Contents

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

  match do |block|
    begin
      block.call
    rescue SystemExit => e
      actual = e.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

7 entries across 7 versions & 1 rubygems

Version Path
kitabu-2.1.0 spec/support/exit_with_code.rb
kitabu-2.0.4 spec/support/exit_with_code.rb
kitabu-2.0.3 spec/support/exit_with_code.rb
kitabu-2.0.2 spec/support/exit_with_code.rb
kitabu-2.0.1 spec/support/exit_with_code.rb
kitabu-2.0.0 spec/support/exit_with_code.rb
kitabu-1.0.6 spec/support/exit_with_code.rb