class ApiSim::Matcher

Constants

OVERRIDE_CLASS_MAP

Public Class Methods

dupe_and_reconfigure(old_matcher, overrides) click to toggle source
# File lib/api_sim/matchers.rb, line 13
def self.dupe_and_reconfigure(old_matcher, overrides)
  if old_matcher.match_on_body?
    Matchers::RequestBodyMatcher.new(
      route: old_matcher.route.to_s,
      http_method: old_matcher.http_method,
      response_code: overrides.fetch(:response_code),
      headers: overrides.fetch(:headers),
      response_body: overrides.fetch(:response_body),
      body_matches: overrides.fetch('matcher', old_matcher.matcher),
    )
  else
    Matchers::StaticRequestMatcher.new(
      route: old_matcher.route.to_s,
      query: old_matcher.query.to_s,
      http_method: old_matcher.http_method,
      response_code: overrides.fetch(:response_code),
      headers: overrides.fetch(:headers),
      response_body: overrides.fetch(:response_body),
      schema: overrides.fetch(:schema),
      request_schema: overrides.fetch(:request_schema)
    )
  end
end