class ApiSim::Matchers::StaticRequestMatcher
Attributes
default[R]
headers[R]
http_method[R]
matcher[R]
query[R]
response_body[R]
response_code[R]
route[R]
schema[R]
Public Class Methods
new(**args)
click to toggle source
# File lib/api_sim/matchers/static_request_matcher.rb, line 10 def initialize(**args) @default = args.fetch(:default, false) @matcher = args.fetch(:matcher, ALWAYS_TRUE_MATCHER) @headers = args.fetch(:headers, {}) @response_body = args.fetch(:response_body, '') @response_code = args.fetch(:response_code, 200) route, @query = args.fetch(:route).split('?') @query ||= args.fetch(:query, '') @route = Mustermann.new(route) @http_method = args.fetch(:http_method) @schema = args.fetch(:schema, nil) @request_schema = args.fetch(:request_schema, nil) end
Public Instance Methods
matches?(request)
click to toggle source
# File lib/api_sim/matchers/static_request_matcher.rb, line 24 def matches?(request) matches_route_pattern?(request) && (query.empty? ? true : request.query_string == query) && request.request_method == http_method && matcher.call(request) end
overridden!()
click to toggle source
# File lib/api_sim/matchers/static_request_matcher.rb, line 31 def overridden! @overridden = true end
overridden?()
click to toggle source
# File lib/api_sim/matchers/static_request_matcher.rb, line 35 def overridden? !!@overridden end
to_s()
click to toggle source
# File lib/api_sim/matchers/static_request_matcher.rb, line 39 def to_s <<-DOC.gsub(/^\s+/, '') #{http_method} #{route} -> (#{response_code}) #{response_body[0..20]}... DOC end