Sha256: 7c82437b800d2d6b2a81aa5183e4a03264e6be4480d7faa16a186886120ca86f

Contents?: true

Size: 544 Bytes

Versions: 2

Compression:

Stored size: 544 Bytes

Contents

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

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wp2middleman-0.0.3 spec/support/matchers/exit_with_code.rb
wp2middleman-0.0.2 spec/support/matchers/exit_with_code.rb