def matches?(given_proc, negative_expectation = false)
if negative_expectation && (expecting_specific_exception? || @expected_message)
what_to_deprecate = if expecting_specific_exception? && @expected_message
"`expect { }.not_to raise_error(SpecificErrorClass, message)`"
elsif expecting_specific_exception?
"`expect { }.not_to raise_error(SpecificErrorClass)`"
elsif @expected_message
"`expect { }.not_to raise_error(message)`"
end
RSpec.deprecate(
what_to_deprecate,
:replacement => "`expect { }.not_to raise_error` (with no args)"
)
end
@raised_expected_error = false
@with_expected_message = false
@eval_block = false
@eval_block_passed = false
unless given_proc.respond_to?(:call)
::Kernel.warn "`raise_error` was called with non-proc object #{given_proc.inspect}"
return false
end
begin
given_proc.call
rescue Exception => @actual_error
if @actual_error == @expected_error || @expected_error === @actual_error
@raised_expected_error = true
@with_expected_message = verify_message
end
end
unless negative_expectation
eval_block if @raised_expected_error && @with_expected_message && @block
end
ensure
return (@raised_expected_error & @with_expected_message) ? (@eval_block ? @eval_block_passed : true) : false
end