35 lines
925 B
Ruby
35 lines
925 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "test_helper"
|
|
|
|
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
|
driven_by(:selenium, using: :headless_chrome,
|
|
options: { browser: :remote,
|
|
url: ENV.fetch("SELENIUM_REMOTE_URL", nil) })
|
|
|
|
setup do
|
|
Capybara.server_host = "0.0.0.0" # bind to all interfaces
|
|
Capybara.app_host = "http://#{IPSocket.getaddress(Socket.gethostname)}" if ENV["SELENIUM_REMOTE_URL"].present?
|
|
end
|
|
|
|
def app_host
|
|
"http://#{IPSocket.getaddress(Socket.gethostname)}"
|
|
end
|
|
|
|
def login(email, password)
|
|
visit "/login"
|
|
fill_in "Login", with: email
|
|
fill_in "Password", with: password
|
|
click_button "Login"
|
|
end
|
|
|
|
def logout
|
|
visit "/logout"
|
|
click_on "Log out"
|
|
end
|
|
|
|
def login_test
|
|
Account.create(email: "test@example.com", password: "password")
|
|
login("test@example.com", "password")
|
|
end
|
|
end
|