Skip to content

Instantly share code, notes, and snippets.

@shdblowers
Created February 3, 2017 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shdblowers/4c071a383862b0fd913db70548aa278e to your computer and use it in GitHub Desktop.
Save shdblowers/4c071a383862b0fd913db70548aa278e to your computer and use it in GitHub Desktop.
defmodule GherkinTests.Contexts.EditUser do
use WhiteBread.Context
alias GherkinTests.State
given_ ~r/^I register a new user called "(?<name>[^"]+)"$/,
fn state, %{name: name} ->
user_details = %{name: name, email: "#{name}@example.com", password: "password123"}
user_id = MyApp.register(user_details)
state = State.store(state, :user_id, user_id)
{:ok, state}
end
when_ ~r/^I change their name to "(?<name>[^"]+)"$/,
fn state, %{name: name} ->
user_id = State.retrieve(state, :user_id)
MyApp.update(user_id, %{name: name})
{:ok, state}
end
# etc...
# etc...
# etc...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment