Skip to content

Instantly share code, notes, and snippets.

@thbar
Created June 29, 2016 19:27
Show Gist options
  • Save thbar/c1b2070eca2f0f8b8e0972ae4537b8d7 to your computer and use it in GitHub Desktop.
Save thbar/c1b2070eca2f0f8b8e0972ae4537b8d7 to your computer and use it in GitHub Desktop.
defmodule WisecashEx.AuthenticationTest do
use WisecashEx.IntegrationCase
setup do
%WisecashEx.User{email: "[email protected]"}
|> WisecashEx.User.auth_changeset(%{password: "testtest"})
|> Repo.insert!
:ok
end
@tag :focus
test "make this work" do
# go to home
navigate_to("/")
"/" = current_path
# click on login link
link = find_element(:link_text, "Login")
click(link)
"/login" = current_path
# fill the form and submit it
find_element(:id, "user_email")
|> fill_field("[email protected]")
find_element(:id, "user_password")
|> fill_field("testtest")
find_element(:tag, "form")
|> submit_element
# verify everything is good
assert visible_page_text =~ ~r/You have been logged in/i
assert visible_page_text =~ ~r/Logged as [email protected]/i
# attempt to logout
find_element(:link_text, "Logout")
|> click
assert visible_page_text =~ ~r/You have been logged out/i
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment