Class: WebMock::RequestExecutionVerifier
- Inherits:
-
Object
- Object
- WebMock::RequestExecutionVerifier
- Defined in:
- lib/webmock/request_execution_verifier.rb
Instance Attribute Summary collapse
-
#at_least_times_executed ⇒ Object
Returns the value of attribute at_least_times_executed.
-
#at_most_times_executed ⇒ Object
Returns the value of attribute at_most_times_executed.
-
#expected_times_executed ⇒ Object
Returns the value of attribute expected_times_executed.
-
#request_pattern ⇒ Object
Returns the value of attribute request_pattern.
-
#times_executed ⇒ Object
Returns the value of attribute times_executed.
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match? ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(request_pattern = nil, expected_times_executed = nil, at_least_times_executed = nil, at_most_times_executed = nil) ⇒ RequestExecutionVerifier
constructor
A new instance of RequestExecutionVerifier.
- #matches? ⇒ Boolean
Constructor Details
#initialize(request_pattern = nil, expected_times_executed = nil, at_least_times_executed = nil, at_most_times_executed = nil) ⇒ RequestExecutionVerifier
Returns a new instance of RequestExecutionVerifier.
6 7 8 9 10 11 |
# File 'lib/webmock/request_execution_verifier.rb', line 6 def initialize(request_pattern = nil, expected_times_executed = nil, at_least_times_executed = nil, at_most_times_executed = nil) @request_pattern = request_pattern @expected_times_executed = expected_times_executed @at_least_times_executed = at_least_times_executed @at_most_times_executed = at_most_times_executed end |
Instance Attribute Details
#at_least_times_executed ⇒ Object
Returns the value of attribute at_least_times_executed.
4 5 6 |
# File 'lib/webmock/request_execution_verifier.rb', line 4 def at_least_times_executed @at_least_times_executed end |
#at_most_times_executed ⇒ Object
Returns the value of attribute at_most_times_executed.
4 5 6 |
# File 'lib/webmock/request_execution_verifier.rb', line 4 def at_most_times_executed @at_most_times_executed end |
#expected_times_executed ⇒ Object
Returns the value of attribute expected_times_executed.
4 5 6 |
# File 'lib/webmock/request_execution_verifier.rb', line 4 def expected_times_executed @expected_times_executed end |
#request_pattern ⇒ Object
Returns the value of attribute request_pattern.
4 5 6 |
# File 'lib/webmock/request_execution_verifier.rb', line 4 def request_pattern @request_pattern end |
#times_executed ⇒ Object
Returns the value of attribute times_executed.
4 5 6 |
# File 'lib/webmock/request_execution_verifier.rb', line 4 def times_executed @times_executed end |
Class Method Details
.executed_requests_message ⇒ Object
48 49 50 |
# File 'lib/webmock/request_execution_verifier.rb', line 48 def self. "\n\nThe following requests were made:\n\n#{RequestRegistry.instance}\n" + "="*60 end |
Instance Method Details
#description ⇒ Object
36 37 38 |
# File 'lib/webmock/request_execution_verifier.rb', line 36 def description "request #{request_pattern} #{quantity_phrase.strip}" end |
#does_not_match? ⇒ Boolean
26 27 28 29 30 31 32 33 34 |
# File 'lib/webmock/request_execution_verifier.rb', line 26 def does_not_match? @times_executed = RequestRegistry.instance.times_executed(@request_pattern) if @expected_times_executed @times_executed != @expected_times_executed else @times_executed == 0 end end |
#failure_message ⇒ Object
40 41 42 |
# File 'lib/webmock/request_execution_verifier.rb', line 40 def (false) end |
#failure_message_when_negated ⇒ Object
44 45 46 |
# File 'lib/webmock/request_execution_verifier.rb', line 44 def (true) end |
#matches? ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/webmock/request_execution_verifier.rb', line 13 def matches? @times_executed = RequestRegistry.instance.times_executed(@request_pattern) if @at_least_times_executed @times_executed >= @at_least_times_executed elsif @at_most_times_executed @times_executed <= @at_most_times_executed else @times_executed == (@expected_times_executed || 1) end end |