Class: Skooma::Objects::Response::Keywords::Headers

Inherits:
JSONSkooma::Keywords::Base
  • Object
show all
Defined in:
lib/skooma/objects/response/keywords/headers.rb

Instance Method Summary collapse

Instance Method Details

#evaluate(instance, result) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/skooma/objects/response/keywords/headers.rb', line 12

def evaluate(instance, result)
  errors = []
  json.each do |key, schema|
    next if ignored_key?(key)

    result.call(instance["headers"], key) do |subresult|
      schema.evaluate(instance["headers"][key], subresult)

      errors << key unless subresult.passed?
    end
  end
  return if errors.empty?

  result.failure("The following headers are invalid: #{errors}")
end