Skip to content

Example in docs does not work  #34

@will-weiss

Description

@will-weiss

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions