aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-23 16:32:28 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-23 20:55:45 +0200
commite0300661068f3c8141cdc90fa915f7c61ce3d1ab (patch)
treebf9c3827a6f7c8269f14442e54d79902835f7e9d /testing/tests
parentbf51e7264fb4273672430f74ce8c2b16a74d1c38 (diff)
downloadaskama-e0300661068f3c8141cdc90fa915f7c61ce3d1ab.tar.gz
askama-e0300661068f3c8141cdc90fa915f7c61ce3d1ab.tar.bz2
askama-e0300661068f3c8141cdc90fa915f7c61ce3d1ab.zip
Add test for Rocket support
Diffstat (limited to '')
-rw-r--r--testing/tests/rocket.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/testing/tests/rocket.rs b/testing/tests/rocket.rs
new file mode 100644
index 0000000..19c1d78
--- /dev/null
+++ b/testing/tests/rocket.rs
@@ -0,0 +1,33 @@
+#![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!");
+}