Class: Ww::Double::Mock::Expectation
- Inherits:
-
Object
- Object
- Ww::Double::Mock::Expectation
- Defined in:
- lib/ww/double/mock/expectation.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Instance Method Summary collapse
- #executed? ⇒ Boolean
-
#initialize(verb, path, verifier = nil, &verify_block) ⇒ Expectation
constructor
A new instance of Expectation.
- #verify(request, testing_thread = nil) ⇒ Object
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
#identifier ⇒ Object (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
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, = _verify(request.dup) return true if passed testing_thread.raise MockError, end |