include ApplicationHelper

def cookie_jar
  Capybara.current_session.driver.browser.current_session.instance_variable_get(:@rack_mock_session).cookie_jar
end

def sign_in(user)
  visit new_user_session_path # login page
  fill_in "Email",    with: user.email
  fill_in "Password", with: user.password
  click_button "Log in"

  # Sign in when not using Capybara as well.
  #cookie_jar[:remember_token] = user.remember_token
end