Class: Ww::Double::Mock::Expectation

Inherits:
Object
  • Object
show all
Defined in:
lib/ww/double/mock.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verb, path, verifier = nil) ⇒ Expectation

Returns a new instance of Expectation.



9
10
11
12
# File 'lib/ww/double/mock.rb', line 9

def initialize(verb, path, verifier = nil)
  @identifier = "_mock_ #{verb.to_s.upcase} #{path}"
  @verifier = verifier
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



7
8
9
# File 'lib/ww/double/mock.rb', line 7

def identifier
  @identifier
end

Instance Method Details

#executed!Object



5
# File 'lib/ww/double/mock.rb', line 5

def executed!; @e = true; end

#executed?Boolean

Returns:

  • (Boolean)


6
# File 'lib/ww/double/mock.rb', line 6

def executed?; !!@e; end

#verify(request, testing_thread = nil) ⇒ Object



14
15
16
17
18
19
# File 'lib/ww/double/mock.rb', line 14

def verify(request, testing_thread = nil)
  return true unless @verifier && testing_thread # no need to verify
  return true if @verifier.call(r = request.dup, r.params)

  testing_thread.raise MockError
end