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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Expectation.



8
9
10
11
12
13
14
15
# File 'lib/ww/double/mock/expectation.rb', line 8

def initialize(verb, path, verifier = nil, &verify_block)
  if verifier && block_given?
    raise ArgumentError, "only one of either argument or block can specified."
  end

  @identifier = "_mock_ #{verb.to_s.upcase} #{path}"
  @verifier = block_given? ? verify_block : verifier
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



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

def identifier
  @identifier
end

Instance Method Details

#executed?Boolean

Returns:

  • (Boolean)


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

def executed?; !!@executed; end

#verify(request, testing_thread = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/ww/double/mock/expectation.rb', line 17

def verify(request, testing_thread = nil)
  @executed = true
  return true unless need_to_verify?(testing_thread)

  passed, message = _verify(request.dup)
  return true if passed

  testing_thread.raise MockError, message
end