Sha256: e6009653c684fa3422dcfb1511f5c546b8883a8c7371bf1af377d76da65d3bc5

Contents?: true

Size: 530 Bytes

Versions: 13

Compression:

Stored size: 530 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_for_should do |block|
    "expected block to call exit(#{code}) but exit" +
    (actual ? "(#{actual}) was called" : " not called")
  end

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

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

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
kitabu-1.0.5 spec/support/exit_with_code.rb
tacape-0.0.6 spec/support/exit_with_code.rb
tacape-0.0.4 spec/support/exit_with_code.rb
tacape-0.0.3 spec/support/exit_with_code.rb
kitabu-1.0.4 spec/support/exit_with_code.rb
kitabu-1.0.3 spec/support/exit_with_code.rb
kitabu-1.0.2 spec/support/exit_with_code.rb
kitabu-1.0.1 spec/support/exit_with_code.rb
kitabu-1.0.0 spec/support/exit_with_code.rb
kitabu-1.0.0.rc4 spec/support/exit_with_code.rb
kitabu-1.0.0.rc3 spec/support/exit_with_code.rb
kitabu-1.0.0.rc2 spec/support/exit_with_code.rb
kitabu-1.0.0.rc1 spec/support/exit_with_code.rb