aboutsummaryrefslogtreecommitdiff
path: root/spec/flows/authentication_spec.cr
blob: b22f93cd756af3d115083ed30de89492de66d480 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require "../spec_helper"

describe "Authentication flow", tags: "flow" do
  it "works" do
    flow = AuthenticationFlow.new("test@example.com")

    flow.sign_up "password"
    flow.should_be_signed_in
    flow.sign_out
    flow.sign_in "wrong-password"
    flow.should_have_password_error
    flow.sign_in "password"
    flow.should_be_signed_in
  end

  # This is to show you how to sign in as a user during tests.
  # Use the `visit` method's `as` option in your tests to sign in as that user.
  #
  # Feel free to delete this once you have other tests using the 'as' option.
  it "allows sign in through backdoor when testing" do
    user = UserFactory.create
    flow = BaseFlow.new

    flow.visit Me::Show, as: user
    should_be_signed_in(flow)
  end
end

private def should_be_signed_in(flow)
  flow.should have_element("@sign-out-button")
end