Class: Stendhal::Mocks::MockVerifier::MessageExpectation
- Defined in:
- lib/stendhal/mocks/mock_verifier.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#times_called ⇒ Object
readonly
Returns the value of attribute times_called.
-
#times_expected ⇒ Object
Returns the value of attribute times_expected.
Instance Method Summary collapse
-
#initialize(method, options = {}) ⇒ MessageExpectation
constructor
A new instance of MessageExpectation.
- #register_call ⇒ Object
- #verify ⇒ Object
Constructor Details
#initialize(method, options = {}) ⇒ MessageExpectation
Returns a new instance of MessageExpectation.
67 68 69 70 71 |
# File 'lib/stendhal/mocks/mock_verifier.rb', line 67 def initialize(method, = {}) @method = method @times_expected = [:negative] ? 0 : 1 @times_called = 0 end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
63 64 65 |
# File 'lib/stendhal/mocks/mock_verifier.rb', line 63 def method @method end |
#times_called ⇒ Object (readonly)
Returns the value of attribute times_called.
64 65 66 |
# File 'lib/stendhal/mocks/mock_verifier.rb', line 64 def times_called @times_called end |
#times_expected ⇒ Object
Returns the value of attribute times_expected.
65 66 67 |
# File 'lib/stendhal/mocks/mock_verifier.rb', line 65 def times_expected @times_expected end |
Instance Method Details
#register_call ⇒ Object
73 74 75 |
# File 'lib/stendhal/mocks/mock_verifier.rb', line 73 def register_call @times_called += 1 end |
#verify ⇒ Object
77 78 79 |
# File 'lib/stendhal/mocks/mock_verifier.rb', line 77 def verify raise Stendhal::Exceptions::ExpectationNotMet.new "expected to be sent :#{method} #{times_expected} time#{times_expected == 1 ? '' : 's'}, but received it #{times_called} time#{times_called == 1 ? '' : 's'}" unless times_expected == times_called end |