Class: ApiSim::Matchers::BaseMatcher
- Inherits:
-
Object
- Object
- ApiSim::Matchers::BaseMatcher
show all
- Defined in:
- lib/api_sim/matchers/base_matcher.rb
Constant Summary
collapse
- DEFAULT_RACK_RESPONSE =
[200, {}, '']
- ALWAYS_TRUE_MATCHER =
->(request) { true }
Instance Method Summary
collapse
Instance Method Details
#custom_matcher? ⇒ Boolean
9
10
11
|
# File 'lib/api_sim/matchers/base_matcher.rb', line 9
def custom_matcher?
matcher != ALWAYS_TRUE_MATCHER
end
|
#match_on_body? ⇒ Boolean
29
30
31
|
# File 'lib/api_sim/matchers/base_matcher.rb', line 29
def match_on_body?
false
end
|
#overridden! ⇒ Object
13
14
15
|
# File 'lib/api_sim/matchers/base_matcher.rb', line 13
def overridden!
@overridden = true
end
|
#overridden? ⇒ Boolean
17
18
19
|
# File 'lib/api_sim/matchers/base_matcher.rb', line 17
def overridden?
!!@overridden
end
|
#readonly? ⇒ Boolean
33
34
35
|
# File 'lib/api_sim/matchers/base_matcher.rb', line 33
def readonly?
false
end
|
#record_request(request) ⇒ Object
37
38
39
40
|
# File 'lib/api_sim/matchers/base_matcher.rb', line 37
def record_request(request)
request.body.rewind
requests.push(RecordedRequest.new(body: request.body.read, request_env: request.env))
end
|
#requests ⇒ Object
25
26
27
|
# File 'lib/api_sim/matchers/base_matcher.rb', line 25
def requests
@requests ||= []
end
|
#reset! ⇒ Object
21
22
23
|
# File 'lib/api_sim/matchers/base_matcher.rb', line 21
def reset!
@overridden = false
end
|
#response(_) ⇒ Object
48
49
50
|
# File 'lib/api_sim/matchers/base_matcher.rb', line 48
def response(_)
[response_code, , response_body]
end
|
#to_s ⇒ Object
42
43
44
45
46
|
# File 'lib/api_sim/matchers/base_matcher.rb', line 42
def to_s
" \#{http_method} \#{route}\n DOC\nend\n".gsub(/^\s+/, '')
|