aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-23 20:43:11 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-23 20:43:11 +0200
commit40775d8c885bda6bd8e086bcc03127c714fc890e (patch)
treeee531e00540470e348f731034723d5e1aa228974 /testing
parente9046c46b7bac87b3f4d89894dd21365360bd3ce (diff)
downloadaskama-40775d8c885bda6bd8e086bcc03127c714fc890e.tar.gz
askama-40775d8c885bda6bd8e086bcc03127c714fc890e.tar.bz2
askama-40775d8c885bda6bd8e086bcc03127c714fc890e.zip
Add test for Iron support
Diffstat (limited to 'testing')
-rw-r--r--testing/Cargo.toml5
-rw-r--r--testing/tests/iron.rs20
2 files changed, 23 insertions, 2 deletions
diff --git a/testing/Cargo.toml b/testing/Cargo.toml
index be9af26..6d81db5 100644
--- a/testing/Cargo.toml
+++ b/testing/Cargo.toml
@@ -6,8 +6,9 @@ workspace = ".."
build = "build.rs"
[dependencies]
+iron = "0.5"
serde_json = "1.0"
-askama = { path = "../askama", version = "*", features = ["serde-json"] }
+askama = { path = "../askama", version = "*", features = ["with-iron", "serde-json"] }
[build-dependencies]
-askama = { path = "../askama", version = "*", features = ["serde-json"] }
+askama = { path = "../askama", version = "*", features = ["with-iron", "serde-json"] }
diff --git a/testing/tests/iron.rs b/testing/tests/iron.rs
new file mode 100644
index 0000000..51c7b8d
--- /dev/null
+++ b/testing/tests/iron.rs
@@ -0,0 +1,20 @@
+#[macro_use]
+extern crate askama;
+extern crate iron;
+
+use askama::Template;
+use iron::{status, Response};
+
+#[derive(Template)]
+#[template(path = "hello.html")]
+struct HelloTemplate<'a> {
+ name: &'a str,
+}
+
+#[test]
+fn test_iron() {
+ let rsp = Response::with((status::Ok, HelloTemplate { name: "world" }));
+ let mut buf = Vec::new();
+ let _ = rsp.body.unwrap().write_body(&mut buf);
+ assert_eq!(buf, "Hello, world!".as_bytes());
+}