Class: Skooma::Matchers::ConformResponseSchema

Inherits:
ConformRequestSchema show all
Defined in:
lib/skooma/matchers/conform_response_schema.rb

Direct Known Subclasses

ConformSchema

Instance Method Summary collapse

Constructor Details

#initialize(skooma, mapped_response, expected) ⇒ ConformResponseSchema

Returns a new instance of ConformResponseSchema.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/skooma/matchers/conform_response_schema.rb', line 8

def initialize(skooma, mapped_response, expected)
  super(skooma, mapped_response)

  @expected = expected

  case expected
  when Symbol
    @expected_code = Rack::Utils::SYMBOL_TO_STATUS_CODE.fetch(expected)
  when Integer
    @expected_code = expected
  else
    raise ArgumentError, "Expected symbol or number, got expected=#{expected.inspect}"
  end
end

Instance Method Details

#descriptionObject



23
24
25
# File 'lib/skooma/matchers/conform_response_schema.rb', line 23

def description
  "conform response schema with #{@expected} response code"
end

#failure_messageObject



33
34
35
36
37
# File 'lib/skooma/matchers/conform_response_schema.rb', line 33

def failure_message
  return "Expected #{@expected} status code, but got #{@mapped_response["response"]["status"]}" unless status_matches?

  super
end

#matches?Boolean

Returns:

  • (Boolean)


27
28
29
30
31
# File 'lib/skooma/matchers/conform_response_schema.rb', line 27

def matches?(*)
  return false unless status_matches?

  super
end