Class: Fitting::Matchers::Response

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

Instance Method Summary collapse

Instance Method Details

#===(other) ⇒ Object



15
16
17
# File 'lib/fitting/matchers/response_matcher.rb', line 15

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

#failure_messageObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fitting/matchers/response_matcher.rb', line 19

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

  unless @response.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.fully_validates}\n"
  end
end

#matches?(response) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
# File 'lib/fitting/matchers/response_matcher.rb', line 7

def matches?(response)
  @response = Fitting::Response.new(
    response,
    Fitting::Storage::Documentation.tomogram
  )
  @response.fully_validates.valid?
end