Created
February 3, 2017 21:53
-
-
Save shdblowers/4c071a383862b0fd913db70548aa278e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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