Class: Mocha::MissingExpectation

Inherits:
Expectation show all
Defined in:
lib/mocha/expectation.rb

Instance Attribute Summary

Attributes inherited from Expectation

#backtrace, #method_name

Instance Method Summary collapse

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_expectationsObject



126
127
128
# File 'lib/mocha/expectation.rb', line 126

def similar_expectations
  @expectations.select { |expectation| expectation.method_name == self.method_name }
end

#verifyObject

Raises:

  • (Test::Unit::AssertionFailedError)


120
121
122
123
124
# File 'lib/mocha/expectation.rb', line 120

def verify
  msg = "Unexpected message #{message}"
  msg << "\nSimilar expectations #{similar_expectations.collect { |expectation| expectation.message }.join("\n") }" unless similar_expectations.empty?
  raise Test::Unit::AssertionFailedError, msg if @invoked
end