Skip to content

module Athena::Framework::Spec::Expectations::HTTP #

Provides expectation helper method for making assertions about the ATH::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#

Asserts the value of the cookie with the provided name, and optionally path and domain, equals that of the provided value

View source

#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.

View source

#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.

View source

#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.

View source

#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.

View source

#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.

View source

#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.

View source

#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.

View source

#assert_response_is_successful(description : String | Nil = nil, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil#

Asserts the response returns with a successful? status code.

View source

#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.

View source

#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.

View source

#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.

View source

#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.

View source

#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.

View source