class Cossack::TestConnection
- Cossack::TestConnection
- Cossack::Connection
- Reference
- Object
Overview
A connection, that is supposed to be used in tests in order to stub HTTP requests.
# Create and stub connection
connection = Cossack::TestConnection.new
connection.stub_get("/hello", {200, "World!"})
Create a client and swap the connection
client = Cossack::Client.new("http://example.org")
client.connection = connection
# Just use client
response = client.get("/hello")
response.status # => 200
response.body # => "World!"
Defined in:
cossack/connection/test_connection.crcossack/connection/test_connection/request_matcher.cr
cossack/connection/test_connection/stub.cr
Constructors
Instance Method Summary
- #call(request : Request) : Response
- #stub_delete(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
- #stub_delete(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
- #stub_delete(url : String, response : Tuple(Int32, String))
- #stub_delete(url : String, response : Tuple(Int32, Hash(String, String), String))
- #stub_get(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
- #stub_get(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
- #stub_get(url : String, response : Tuple(Int32, String))
- #stub_get(url : String, response : Tuple(Int32, Hash(String, String), String))
- #stub_head(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
- #stub_head(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
- #stub_head(url : String, response : Tuple(Int32, String))
- #stub_head(url : String, response : Tuple(Int32, Hash(String, String), String))
- #stub_options(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
- #stub_options(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
- #stub_options(url : String, response : Tuple(Int32, String))
- #stub_options(url : String, response : Tuple(Int32, Hash(String, String), String))
- #stub_patch(url : String, headers : Hash(String, String), body : String, response : Tuple(Int32, String))
- #stub_patch(url : String, headers : Hash(String, String), body : String, response : Tuple(Int32, Hash(String, String), String))
- #stub_patch(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
- #stub_patch(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
- #stub_patch(url : String, body : String, response : Tuple(Int32, String))
- #stub_patch(url : String, body : String, response : Tuple(Int32, Hash(String, String), String))
- #stub_patch(url : String, response : Tuple(Int32, String))
- #stub_patch(url : String, response : Tuple(Int32, Hash(String, String), String))
- #stub_post(url : String, headers : Hash(String, String), body : String, response : Tuple(Int32, String))
- #stub_post(url : String, headers : Hash(String, String), body : String, response : Tuple(Int32, Hash(String, String), String))
- #stub_post(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
- #stub_post(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
- #stub_post(url : String, body : String, response : Tuple(Int32, String))
- #stub_post(url : String, body : String, response : Tuple(Int32, Hash(String, String), String))
- #stub_post(url : String, response : Tuple(Int32, String))
- #stub_post(url : String, response : Tuple(Int32, Hash(String, String), String))
- #stub_put(url : String, headers : Hash(String, String), body : String, response : Tuple(Int32, String))
- #stub_put(url : String, headers : Hash(String, String), body : String, response : Tuple(Int32, Hash(String, String), String))
- #stub_put(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
- #stub_put(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
- #stub_put(url : String, body : String, response : Tuple(Int32, String))
- #stub_put(url : String, body : String, response : Tuple(Int32, Hash(String, String), String))
- #stub_put(url : String, response : Tuple(Int32, String))
- #stub_put(url : String, response : Tuple(Int32, Hash(String, String), String))
Instance methods inherited from class Cossack::Connection
call(request : Request) : Response
call
Constructor Detail
Instance Method Detail
def stub_delete(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
#
def stub_delete(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
#
def stub_delete(url : String, response : Tuple(Int32, Hash(String, String), String))
#
def stub_get(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
#
def stub_get(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
#
def stub_head(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
#
def stub_head(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
#
def stub_options(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
#
def stub_options(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
#
def stub_options(url : String, response : Tuple(Int32, Hash(String, String), String))
#
def stub_patch(url : String, headers : Hash(String, String), body : String, response : Tuple(Int32, String))
#
def stub_patch(url : String, headers : Hash(String, String), body : String, response : Tuple(Int32, Hash(String, String), String))
#
def stub_patch(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
#
def stub_patch(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
#
def stub_patch(url : String, body : String, response : Tuple(Int32, Hash(String, String), String))
#
def stub_post(url : String, headers : Hash(String, String), body : String, response : Tuple(Int32, String))
#
def stub_post(url : String, headers : Hash(String, String), body : String, response : Tuple(Int32, Hash(String, String), String))
#
def stub_post(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
#
def stub_post(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
#
def stub_post(url : String, body : String, response : Tuple(Int32, Hash(String, String), String))
#
def stub_put(url : String, headers : Hash(String, String), body : String, response : Tuple(Int32, String))
#
def stub_put(url : String, headers : Hash(String, String), body : String, response : Tuple(Int32, Hash(String, String), String))
#
def stub_put(url : String, headers : Hash(String, String), response : Tuple(Int32, String))
#
def stub_put(url : String, headers : Hash(String, String), response : Tuple(Int32, Hash(String, String), String))
#
def stub_put(url : String, body : String, response : Tuple(Int32, Hash(String, String), String))
#