Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example in docs does not work #34

Open
will-weiss opened this issue Jun 14, 2016 · 0 comments
Open

Example in docs does not work #34

will-weiss opened this issue Jun 14, 2016 · 0 comments

Comments

@will-weiss
Copy link

will-weiss commented Jun 14, 2016

Description

Executing cargo test with the provided example does not work.

$ cargo test                                                                                                                                                                        ✱
   Compiling hello-world v0.0.1 (file:///Users/willweiss/dev/rust/hello-world)
src/main.rs:21:64: 21:70 error: no method named `unwrap` found for type `iron::Response` in the current scope
src/main.rs:21     let result_body = response::extract_body_to_bytes(response.unwrap());
                                                                              ^~~~~~
error: aborting due to previous error
error: Could not compile `hello-world`.

Changing the test to read:

#[test]
fn test_hello_world() {
    let res = request::get("http://localhost:3000/hello",
                                Headers::new(),
                                &HelloWorldHandler).unwrap();
    let result_body = response::extract_body_to_bytes(res);

    assert_eq!(result_body, b"Hello, world!");
}

Fixes the issue as iron_test::response::extract_body_to_bytes takes an argument of type iron::response::Response per the docs.

Thanks in advance!

Environment

darwin 14.5.0
cargo 0.10.0-nightly (10ddd7d 2016-04-08)
iron 0.3.0
iron-test 0.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant