Gabira
A rust library for testing HTTP servers. It focuses on ergonomics and brevity.
Documentation:
Usage
Add the following dependency to your Cargo.toml:
[]
= "0.1"
and import it in your tests:
extern crate gabira;
use *;
Example
get
.expect_status // <- Assert http status code
.expect_body // <- Assert response body
.end; // <- Consume the test. Compile-time warnings are issued if forgotten.
Here's an example with actix-web's TestServer:
let srv = with_factory;
// POST request with json body
post
.send_json.expect_status
.expect_json
.end;
Expectations can be chained:
let invoice: InvoiceDto = post
.set_header
.set_header
.send_json
.expect_status
.expect_header
.expect_header
.expect
.expect
.end_json_with;
process_invoice;
API
get
post
put
delete
.set_cookie
.set_header
.send
.send_json
.send_form
.expect_status
.expect_cookie
.expect_header
.expect_json
.expect_form
.expect_body
.expect
.end .end_with . .
Functionality
- Requests are synchronous
- Expectations (e.g.
expect_status
,expect_json
) are run in the order of definition
Limitations
Range of assertions are limited for the moment. See the documentation.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.