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



43
44
45
# File 'lib/fitting/matchers/response_matcher.rb', line 43

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

#failure_messageObject



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fitting/matchers/response_matcher.rb', line 47

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

  unless @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
end

#matches?(response) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
39
40
41
# File 'lib/fitting/matchers/response_matcher.rb', line 35

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