pub struct Mock { /* fields omitted */ }Stores information about a mocked request. Should be initialized via mockito::mock().
Allows matching a particular request header when responding with a mock.
When matching a request, the field letter case is ignored.
use mockito::mock;
let _m = mock("GET", "/").match_header("content-type", "application/json");
Like most other Mock methods, it allows chanining:
use mockito::mock;
let _m = mock("GET", "/")
.match_header("content-type", "application/json")
.match_header("authorization", "password");
Allows matching a particular request body when responding with a mock.
use mockito::mock;
let _m1 = mock("POST", "/").match_body("{'hello':'world'}").with_body("json").create();
let _m2 = mock("POST", "/").match_body("hello=world").with_body("form").create();
Sets the status code of the mock response. The default status code is 200.
use mockito::mock;
let _m = mock("GET", "/").with_status(201);
Sets a header of the mock response.
use mockito::mock;
let _m = mock("GET", "/").with_header("content-type", "application/json");
Sets the body of the mock response. Its Content-Length is handled automatically.
use mockito::mock;
let _m = mock("GET", "/").with_body("hello world");
Sets the body of the mock response from the contents of a file stored under path.
Its Content-Length is handled automatically.
use mockito::mock;
let _m = mock("GET", "/").with_body_from_file("tests/files/simple.http");
Sets the expected amount of requests that this mock is supposed to receive.
This is only enforced when calling the assert method.
Defaults to 1 request.
Asserts that the expected amount of requests (defaults to 1 request) were performed.
Registers the mock to the server - your mock will be served only after calling this method.
use mockito::mock;
let _m = mock("GET", "/").with_body("hello world").create();
Performs copy-assignment from source. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=.
Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more
Formats the value using the given formatter. Read more