Sha256: 4dc796d5a7c1b0669a7a778e4427605a0a08620c4dbd978116a7d985bb311184
Contents?: true
Size: 925 Bytes
Versions: 16
Compression:
Stored size: 925 Bytes
Contents
RSpec::Matchers.define_negated_matcher :exit_without_error, :exit_with_error RSpec::Matchers.define :exit_with_error do def supports_block_expectations? true end match do |block| begin block.call rescue SystemExit => e @exit_status = e.status end !@exit_status.nil? && @exit_status == expected_status end chain :status do |status| @expected_status = status end failure_message do |block| "expected block to exit with status #{expected_status} but exit " + (@exit_status.nil? ? "was not called" : "status was #{@exit_status}") end failure_message_when_negated do |block| "expected block not to raise SystemExit, got exit with status #{@exit_status}" end description do "expect block to exit #{expected_status.zero? ? "without error" : "with error (status #{expected_status})"}" end def expected_status @expected_status ||= 1 end end
Version data entries
16 entries across 16 versions & 1 rubygems