Class: Mocha::MissingExpectation
- Inherits:
-
Expectation
- Object
- Expectation
- Mocha::MissingExpectation
- Defined in:
- lib/mocha/expectation.rb
Instance Attribute Summary
Attributes inherited from Expectation
Instance Method Summary collapse
-
#initialize(method_name, expectations = []) ⇒ MissingExpectation
constructor
A new instance of MissingExpectation.
- #similar_expectations ⇒ Object
- #verify ⇒ Object
Methods inherited from Expectation
#at_least, #at_least_once, #invoke, #match?, #message, #never, #raises, #returns, #times, #with, #yield?, #yields
Constructor Details
#initialize(method_name, expectations = []) ⇒ MissingExpectation
Returns a new instance of MissingExpectation.
114 115 116 117 118 |
# File 'lib/mocha/expectation.rb', line 114 def initialize(method_name, expectations = []) super(method_name) @expectations = expectations @invoked = true end |
Instance Method Details
#similar_expectations ⇒ Object
126 127 128 |
# File 'lib/mocha/expectation.rb', line 126 def similar_expectations @expectations.select { |expectation| expectation.method_name == self.method_name } end |
#verify ⇒ Object
120 121 122 123 124 |
# File 'lib/mocha/expectation.rb', line 120 def verify msg = "Unexpected message #{}" msg << "\nSimilar expectations #{similar_expectations.collect { |expectation| expectation. }.join("\n") }" unless similar_expectations.empty? raise Test::Unit::AssertionFailedError, msg if @invoked end |