Sha256: d62c70c7a39b289c37f20f2c7efe28945a99abaa9b39d59566cfb26f98e01bcf
Contents?: true
Size: 1.02 KB
Versions: 9
Compression:
Stored size: 1.02 KB
Contents
module Minitest::Assertions def assert_response_status(status) assert last_response.code == status.to_s, "The actual response status is #{last_response.code}" end def assert_response_content_type(content_type) assert last_response['Content-Type'] == content_type.to_s, "The actual response content_type is #{last_response['Content-Type']}" end def assert_response_headers(headers, options = {}) exclude_keys = Array(options[:exclude] || []) response_headers = last_response.to_hash.delete_if {|k, _| exclude_keys.include?(k)} assert response_headers == headers, "The actual response headers are #{response_headers.inspect}" end def assert_response_body(body_string) assert last_response.body == body_string, "The actual response body is #{last_response.body}" end def assert_response_json_schema(schema_path) schema = File.open(schema_path).read assert JSON::Validator.validate(schema, last_response.body), "The actual response does not match the schema defined in #{schema_path}" end end
Version data entries
9 entries across 9 versions & 1 rubygems