diff --git a/examples/templating/src/main.rs b/examples/templating/src/main.rs index 4cc605dc19..4eae318192 100644 --- a/examples/templating/src/main.rs +++ b/examples/templating/src/main.rs @@ -14,7 +14,9 @@ use rocket_dyn_templates::Template; #[get("/")] fn index() -> RawHtml<&'static str> { RawHtml( - r#"See Tera, Handlebars, or MiniJinja."#, + r#"See Tera, + Handlebars, + or MiniJinja."#, ) } diff --git a/examples/templating/src/minijinja.rs b/examples/templating/src/minijinja.rs index 3efaf9ac25..799a1a9c50 100644 --- a/examples/templating/src/minijinja.rs +++ b/examples/templating/src/minijinja.rs @@ -35,7 +35,7 @@ pub fn about() -> Template { #[catch(404)] pub fn not_found(req: &Request<'_>) -> Template { println!("Handling 404 for URI: {}", req.uri()); - + Template::render( "minijinja/error/404", context! { diff --git a/examples/templating/src/tests.rs b/examples/templating/src/tests.rs index e4caa030fd..e532f21169 100644 --- a/examples/templating/src/tests.rs +++ b/examples/templating/src/tests.rs @@ -35,25 +35,23 @@ fn test_name(base: &str) { assert!(response.into_string().unwrap().contains("Hi Jack Daniels!")); } + fn test_404(base: &str) { // Check that the error catcher works. let client = Client::tracked(rocket()).unwrap(); for bad_path in &["/hello", "/foo/bar", "/404"] { let path = format!("/{}{}", base, bad_path); - - let escaped_path_upper = RawStr::new(&path).html_escape(); - let escaped_path_lower = escaped_path_upper.to_lowercase(); + let escaped_path = RawStr::new(&path).html_escape().to_lowercase(); let response = client.get(&path).dispatch(); assert_eq!(response.status(), Status::NotFound); - let response = response.into_string().unwrap(); + let response = response.into_string().unwrap().to_lowercase(); - assert!(response.contains(base)); - assert!( - response.contains(&format!("{} does not exist", path)) || - response.contains(&format!("{} does not exist", escaped_path_upper)) || - response.contains(&format!("{} does not exist", escaped_path_lower)) - ); + assert!(response.contains(base)); + assert! { + response.contains(&format!("{} does not exist", path)) + || response.contains(&format!("{} does not exist", escaped_path)) + }; } }