Sync testing exmaple with guide.

This commit is contained in:
Sergio Benitez 2016-12-23 02:39:10 -08:00
parent b0f1263c0e
commit 2cf7e2c6cd
1 changed files with 2 additions and 0 deletions

View File

@ -16,6 +16,7 @@ fn main() {
mod test {
use super::rocket;
use rocket::testing::MockRequest;
use rocket::http::Status;
use rocket::http::Method::*;
#[test]
@ -23,6 +24,7 @@ mod test {
let rocket = rocket::ignite().mount("/", routes![super::hello]);
let mut req = MockRequest::new(Get, "/");
let mut response = req.dispatch_with(&rocket);
assert_eq!(response.status(), Status::Ok);
let body_string = response.body().and_then(|b| b.into_string());
assert_eq!(body_string, Some("Hello, world!".to_string()));