module Minitest::Assertions
Public Instance Methods
assert_response_body(body_string)
click to toggle source
# File lib/dock_test/assertions.rb, line 16 def assert_response_body(body_string) assert last_response.body == body_string, "The actual response body is #{last_response.body}" end
assert_response_content_type(content_type)
click to toggle source
# File lib/dock_test/assertions.rb, line 6 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
assert_response_headers(headers, options = {})
click to toggle source
# File lib/dock_test/assertions.rb, line 10 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
assert_response_json_schema(schema_path)
click to toggle source
# File lib/dock_test/assertions.rb, line 20 def assert_response_json_schema(schema_path) schema = File.open(schema_path).read errors = JSON::Validator.fully_validate(schema, last_response.body) assert errors.empty?, "The actual response does not match the schema defined in #{schema_path} because #{errors.join(', ')}" end
assert_response_status(status)
click to toggle source
# File lib/dock_test/assertions.rb, line 2 def assert_response_status(status) assert last_response.code == status.to_s, "The actual response status is #{last_response.code}" end
assert_response_xml_schema(schema_path)
click to toggle source
# File lib/dock_test/assertions.rb, line 26 def assert_response_xml_schema(schema_path) schema = ::Nokogiri::XML::Schema(File.read(schema_path)) document = ::Nokogiri::XML(last_response.body) assert document.root && schema.valid?(document), "The actual response does not match the schema defined in #{schema_path} because #{schema.validate(document)}" end