blob: 19c1d7829dc8c9b94c553baae48ad2ae18c607e7 (
plain) (
tree)
|
|
#![cfg(feature = "rocket")]
#![feature(plugin)]
#![plugin(rocket_codegen)]
#[macro_use]
extern crate askama;
extern crate rocket;
use askama::Template;
use rocket::local::Client;
use rocket::http::{ContentType, Status};
#[derive(Template)]
#[template(path = "hello.html")]
struct HelloTemplate<'a> {
name: &'a str,
}
#[get("/")]
fn hello() -> HelloTemplate<'static> {
HelloTemplate { name: "world" }
}
#[test]
fn test_rocket() {
let rocket = rocket::ignite().mount("/", routes![hello]);
let client = Client::new(rocket).unwrap();
let mut rsp = client.get("/").dispatch();
assert_eq!(rsp.status(), Status::Ok);
assert_eq!(rsp.content_type(), Some(ContentType::HTML));
assert_eq!(rsp.body_string().unwrap(), "Hello, world!");
}
|