class Pacto::Validators::ResponseBodyValidator
Public Class Methods
new(app)
click to toggle source
# File lib/pacto/validators/response_body_validator.rb, line 4 def initialize(app) @app = app end
section_name()
click to toggle source
# File lib/pacto/validators/response_body_validator.rb, line 8 def self.section_name 'response' end
subschema(contract)
click to toggle source
# File lib/pacto/validators/response_body_validator.rb, line 12 def self.subschema(contract) contract.response.schema end
Public Instance Methods
call(env)
click to toggle source
# File lib/pacto/validators/response_body_validator.rb, line 16 def call(env) if env[:validation_results].empty? # skip body validation if we already have other errors actual_body = env[:actual_response] errors = self.class.validate(env[:contract], actual_body) env[:validation_results].concat errors.compact end @app.call env end