forked from bblimke/webmock
/
webmock_matcher.rb
46 lines (36 loc) · 1023 Bytes
/
webmock_matcher.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module WebMock
class WebMockMatcher
def initialize(method, uri)
@request_execution_verifier = RequestExecutionVerifier.new
@request_execution_verifier.request_pattern = RequestPattern.new(method, uri)
end
def once
@request_execution_verifier.expected_times_executed = 1
self
end
def twice
@request_execution_verifier.expected_times_executed = 2
self
end
def with(options = {}, &block)
@request_execution_verifier.request_pattern.with(options, &block)
self
end
def times(times)
@request_execution_verifier.expected_times_executed = times.to_i
self
end
def matches?(webmock)
@request_execution_verifier.matches?
end
def does_not_match?(webmock)
@request_execution_verifier.does_not_match?
end
def failure_message
@request_execution_verifier.failure_message
end
def negative_failure_message
@request_execution_verifier.negative_failure_message
end
end
end