HashNuke / hound

Elixir library for writing integration tests and browser automation

Home Page:http://hexdocs.pm/hound

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Modular Functionality

sitch opened this issue · comments

commented

I was having an issue trying to split off some common functionality -- would love if someone could help out with an answer

defmodule MyApp.Support.Integration.SignInHelper do
  use Hound.Helpers

  def sign_in(user) do
    navigate_to "/sign_in"
  end

end
defmodule MyApp.OtherPageIntegrationTest do
  use MyApp.IntegrationCase
  import MyApp.Support.Integration.SignInHelper

  setup do
    user = %{username: "name", password: "password"}
    sign_in(user)
    {:ok, %{user: user}}
 end

  test "can view", %{user: user} do
    assert visible_page_text() =~ user.username
  end

end

What would happen is the SignInHelper.sign_in/1 gets called but then the browser quits.
Seems like the session gets taken away when I use this kind of modular style for writing the tests. Maybe someone can help out?