Sha256: c070c014a6a2ea1c7bf45af63a0bb346c9d73f677eeb41c9f5c2401927763626
Contents?: true
Size: 887 Bytes
Versions: 9
Compression:
Stored size: 887 Bytes
Contents
require 'rspec/expectations' RSpec::Matchers.define :abort_with_error do |message| match do |block| @block = block with_fake_stderr do @got_system_exit = false begin block.call rescue SystemExit @got_system_exit = true @stderr = $stderr.string message ? message === @stderr : true else false end end end description do "blahhh" end failure_message_for_should do |actual| if @got_system_exit "expected STDERR to match " + \ ((message.is_a?(Regexp) ? "/%s/" : "'%s'") % message) + \ " but got:\n#{@stderr}" else "expected #{@block} to raise SystemExit" end end # Fake STDERR and return a string written to it. def with_fake_stderr original_stderr = $stderr $stderr = StringIO.new yield ensure $stderr = original_stderr end end
Version data entries
9 entries across 9 versions & 2 rubygems