module
Amber::Testing::RequestHelpers
Overview
Provides HTTP request helper methods for use in specs. Include this module in your spec context to make requests against the Amber application without starting a real server.
Requests are routed through the Amber pipeline programmatically, using the routes and pipes configured on Amber::Server.
describe "MyController" do
include Amber::Testing::RequestHelpers
it "returns a list of items" do
response = get("/items")
response.status_code.should eq(200)
end
end
Defined in:
amber/testing/request_helpers.crInstance Method Summary
-
#delete(path : String, headers : HTTP::Headers | Nil = nil) : TestResponse
Send a DELETE request to the given path.
-
#get(path : String, headers : HTTP::Headers | Nil = nil) : TestResponse
Send a GET request to the given path.
-
#head(path : String, headers : HTTP::Headers | Nil = nil) : TestResponse
Send a HEAD request to the given path.
-
#patch(path : String, body : String | Nil = nil, headers : HTTP::Headers | Nil = nil) : TestResponse
Send a PATCH request to the given path with an optional body.
-
#patch_json(path : String, body) : TestResponse
Send a PATCH request with a JSON body.
-
#post(path : String, body : String | Nil = nil, headers : HTTP::Headers | Nil = nil) : TestResponse
Send a POST request to the given path with an optional body.
-
#post_json(path : String, body) : TestResponse
Send a POST request with a JSON body.
-
#put(path : String, body : String | Nil = nil, headers : HTTP::Headers | Nil = nil) : TestResponse
Send a PUT request to the given path with an optional body.
-
#put_json(path : String, body) : TestResponse
Send a PUT request with a JSON body.
Instance Method Detail
Send a DELETE request to the given path.
Send a GET request to the given path.
Send a HEAD request to the given path.
Send a PATCH request to the given path with an optional body.
Send a PATCH request with a JSON body. Automatically sets the Content-Type header to application/json.
Send a POST request to the given path with an optional body.
Send a POST request with a JSON body. Automatically sets the Content-Type header to application/json.
Send a PUT request to the given path with an optional body.
Send a PUT request with a JSON body. Automatically sets the Content-Type header to application/json.