Method: Hardmock#verify_mocks
- Defined in:
- lib/hardmock.rb
#verify_mocks(force = true) ⇒ Object Also known as: verify_hardmocks
Ensures that all expectations have been met. If not, VerifyException is raised.
You normally won’t need to call this yourself. Within Test::Unit::TestCase, this will be done automatically at teardown time.
-
force
– iffalse
, and a VerifyError or ExpectationError has already occurred, this method will not raise. This is to help you suppress repeated errors when if you’re calling #verify_mocks in the teardown method of your test suite. BE WARNED - only use this if you’re sure you aren’t obscuring useful information. Eg, if your code handles exceptions internally, and an ExpectationError gets gobbled up by yourrescue
block, the cause of failure for your test may be hidden from you. For this reason, #verify_mocks defaults to force=true as of Hardmock 1.0.1
61 62 63 64 65 66 67 68 69 |
# File 'lib/hardmock.rb', line 61 def verify_mocks(force=true) return unless @main_mock_control return if @main_mock_control.disappointed? and !force @main_mock_control.verify ensure @main_mock_control.clear_expectations if @main_mock_control $main_mock_control = nil reset_stubs end |