aboutsummaryrefslogtreecommitdiff
path: root/spec/flows/authentication_spec.cr
diff options
context:
space:
mode:
Diffstat (limited to 'spec/flows/authentication_spec.cr')
-rw-r--r--spec/flows/authentication_spec.cr31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/flows/authentication_spec.cr b/spec/flows/authentication_spec.cr
new file mode 100644
index 0000000..b22f93c
--- /dev/null
+++ b/spec/flows/authentication_spec.cr
@@ -0,0 +1,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