module Athena::Framework::Spec::Expectations::HTTP
#
Provides expectation helper method for making assertions about the AHTTP::Request and/or ::HTTP::Server::Response of a controller action.
For example asserting the response is successful, has a specific header/cookie (value), and/or if the request has an attribute with a specific value.
struct ExampleControllerTest < ATH::Spec::APITestCase
def test_root : Nil
self.get "/"
self.assert_response_is_successful
end
end
Some expectations will also print more information upon failure to make it easier to understand why it failed.
#assert_response_is_successful for example will include the response status, headers, and body as well as the exception that caused the failure if applicable.
Direct including types
Athena::Framework::Spec::WebTestCase
Methods#
#assert_browser_cookie_has_value(name : String, value : String, path : String = "/", domain : String | Nil = nil, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the value of the browser's cookie with the provided name, and optionally path and domain, equals that of the provided value.
#assert_browser_has_cookie(name : String, path : String = "/", domain : String | Nil = nil, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the browser has a cookie with the provided name, and optionally path and domain, that would be sent with subsequent requests.
#assert_browser_not_has_cookie(name : String, path : String = "/", domain : String | Nil = nil, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the browser does not have a cookie with the provided name, and optionally path and domain.
#assert_cookie_has_value(name : String, value : String, path : String | Nil = nil, domain : String | Nil = nil, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the value of the cookie with the provided name, and optionally path and domain, equals that of the provided value
#assert_request_attribute_equals(name : String, value : _, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the request attribute with the provided name equals the provided value.
#assert_response_format_equals(format : String, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the format of the response equals the provided format.
#assert_response_has_cookie(name : String, path : String | Nil = nil, domain : String | Nil = nil, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the response has a cookie with the provided name, and optionally path and domain.
#assert_response_has_header(name : String, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the response has a header with the provided name.
#assert_response_has_status(status : ::HTTP::Status | Int32, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the response has the same status as the one provided.
#assert_response_header_equals(name : String, value : String, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the value of the header with the provided name, equals that of the provided value.
#assert_response_header_not_equals(name : String, value : String, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the value of the header with the provided name, does not equal that of the provided value.
#assert_response_is_successful(description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the response returns with a successful? status code.
#assert_response_is_unprocessable(description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the response returns with status of 422 Unprocessable Entity.
#assert_response_not_has_cookie(name : String, path : String | Nil = nil, domain : String | Nil = nil, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the response does not have a cookie with the provided name, and optionally path and domain.
#assert_response_not_has_header(name : String, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the response does not have a header with the provided name.
#assert_response_redirects(location : String | Nil = nil, status : ::HTTP::Status | Int32 | Nil = nil, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the response returns with a redirection? status code.
Optionally allows also asserting the location header is that of the provided location,
and/or the status is equal to the provided status.
#assert_route_equals(name : String, parameters : Hash | Nil = nil, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the request was matched against the route with the provided name.
#assert_session_has_flash_message(type : String, message : String | Array(String) | Nil = nil, description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#
Asserts the session of the request has a flash message of the provided type. Optionally asserts one of its messages is the provided message, or one of the provided messages.
Flash messages read by the request, e.g. via AHTTP::Session::FlashBag#get, are no longer in the session.