Class: ApiValidator::Header
- Inherits:
-
Base
- Object
- Base
- ApiValidator::Header
show all
- Defined in:
- lib/api-validator/header.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#assertions, #initialize
Class Method Details
.named_expectations ⇒ Object
4
5
6
|
# File 'lib/api-validator/header.rb', line 4
def self.named_expectations
@named_expectations ||= {}
end
|
.register(name, expected) ⇒ Object
8
9
10
|
# File 'lib/api-validator/header.rb', line 8
def self.register(name, expected)
named_expectations[name] = expected
end
|
Instance Method Details
#validate(response) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/api-validator/header.rb', line 12
def validate(response)
compiled_assertions = compile_assertions(response)
= response.env[:response_headers]
_failed_assertions = failed_assertions(compiled_assertions, )
super.merge(
:assertions => compiled_assertions.map(&:to_hash),
:key => :response_headers,
:failed_assertions => _failed_assertions.map(&:to_hash),
:diff => diff(, _failed_assertions).map(&:to_hash),
:valid => _failed_assertions.empty?
)
end
|