Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
the10thWiz committed May 9, 2022
1 parent 00da4df commit f0ccdbe
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/codegen/src/attribute/catch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub fn _catch(
name: stringify!(#user_catcher_fn_name),
code: #status_code,
handler: monomorphized_function,
route_type: #_Box::new(self),
catcher_type: #_Box::new(self),
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/lib/src/local/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ macro_rules! pub_response_impl {
/// # Example
///
/// ```rust
/// # use rocket::get;
/// # use rocket::catch;
/// #[catch(404)]
/// fn default_404() -> &'static str { "Hello World" }
#[doc = $doc_prelude]
Expand Down
25 changes: 20 additions & 5 deletions examples/hello/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ fn hello() {

let uri = format!("/?{}{}{}", q("lang", lang), q("emoji", emoji), q("name", name));
let response = client.get(uri).dispatch();
assert!(response.routed_by::<super::hello>(), "Response was not generated by the `hello` route");
assert!(
response.routed_by::<super::hello>(),
"Response was not generated by the `hello` route"
);
assert_eq!(response.into_string().unwrap(), expected);

let uri = format!("/?{}{}{}", q("emoji", emoji), q("name", name), q("lang", lang));
let response = client.get(uri).dispatch();
assert!(response.routed_by::<super::hello>(), "Response was not generated by the `hello` route");
assert!(
response.routed_by::<super::hello>(),
"Response was not generated by the `hello` route"
);
assert_eq!(response.into_string().unwrap(), expected);
}
}
Expand All @@ -44,7 +50,10 @@ fn hello() {
fn hello_world() {
let client = Client::tracked(super::rocket()).unwrap();
let response = client.get("/hello/world").dispatch();
assert!(response.routed_by::<super::world>(), "Response was not generated by the `world` route");
assert!(
response.routed_by::<super::world>(),
"Response was not generated by the `world` route"
);
assert_eq!(response.into_string(), Some("Hello, world!".into()));
}

Expand All @@ -64,13 +73,19 @@ fn wave() {
let real_name = RawStr::new(name).percent_decode_lossy();
let expected = format!("👋 Hello, {} year old named {}!", age, real_name);
let response = client.get(uri).dispatch();
assert!(response.routed_by::<super::wave>(), "Response was not generated by the `wave` route");
assert!(
response.routed_by::<super::wave>(),
"Response was not generated by the `wave` route"
);
assert_eq!(response.into_string().unwrap(), expected);

for bad_age in &["1000", "-1", "bird", "?"] {
let bad_uri = format!("/wave/{}/{}", name, bad_age);
let response = client.get(bad_uri).dispatch();
assert!(response.caught_by::<rocket::catcher::DefaultCatcher>(), "Response was not generated by the default catcher");
assert!(
response.caught_by::<rocket::catcher::DefaultCatcher>(),
"Response was not generated by the default catcher"
);
assert_eq!(response.status(), Status::NotFound);
}
}
Expand Down

0 comments on commit f0ccdbe

Please sign in to comment.