summaryrefslogtreecommitdiff
path: root/spec/support/sessions_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/sessions_helper.rb')
-rw-r--r--spec/support/sessions_helper.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/support/sessions_helper.rb b/spec/support/sessions_helper.rb
new file mode 100644
index 0000000..eeb12d8
--- /dev/null
+++ b/spec/support/sessions_helper.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+# Module to generate JWTs for use in specs.
+module SessionsHelper
+ def jwt(user)
+ user_params = { credentials: { email: user.email, password: user.password } }
+ post('/api/authenticate', user_params.to_json)
+ JSON.parse(response.body)['token']
+ end
+end \ No newline at end of file