July 2017
Intermediate to advanced
284 pages
6h 45m
English
We can eliminate this code in TrueStory with story pipes, like this:
| | ... |
| | # this example is simplified for clarity |
| | |
| | def configure_web_app(c, ...) do |
| | c |
| | |> Map.put :conn, set_up_test_conn(...) |
| | end |
| | |
| | def logged_in(c, user) do |
| | c |
| | |> Map.put :session, log_in(new_user, c.conn) |
| | end |
| | def get_root(c) do |
| | c |
| | |> Map.put :response, get_root(c.conn) |
| | end |
| | |
| | story "getting /", c |
| | |> configure_web_app |
| | |> get_root, |
| | verify do |
| | assert c.conn.response == :redirect |
| | # more assertions about an unauthorized get |
| | end |
| | |
| | story "getting /, logged in", c |
| | |> configure_web_app |
| | |> logged_in(create_user) |
| | |> get_root, |
| | verify do |
| | assert c.conn.response ... |
Read now
Unlock full access