Class: Fitting::Matchers::StrictResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/fitting/matchers/response_matcher.rb

Instance Method Summary collapse

Instance Method Details

#===(other) ⇒ Object



58
59
60
# File 'lib/fitting/matchers/response_matcher.rb', line 58

def ===(other)
  matches?(other)
end

#failure_messageObject



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/fitting/matchers/response_matcher.rb', line 62

def failure_message
  unless @response.documented?
    return "response not documented\n"\
           "got: #{@response.real_request_with_status}"
  end

  return nil if @response.strict_fully_validates.valid?

  "response does not conform to json-schema\n"\
    "schemas: \n#{@response.expected}\n\n"\
    "got: #{@response.got}\n\n"\
    "errors: \n#{@response.strict_fully_validates}\n"
end

#matches?(response) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
53
54
55
56
# File 'lib/fitting/matchers/response_matcher.rb', line 50

def matches?(response)
  if Fitting.configuration.is_a?(Array)
    one_match(response, Fitting.configuration[0])
  else
    one_match(response, Fitting.configuration)
  end
end