summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/authentications_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/requests/authentications_spec.rb b/spec/requests/authentications_spec.rb
new file mode 100644
index 0000000..2ee8ead
--- /dev/null
+++ b/spec/requests/authentications_spec.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+RSpec.describe 'Authentications', type: :request do
+ let(:user) { create(:user_account) }
+ let(:params) { { credentials: { email: user.email, password: user.password } } }
+ let(:headers) { { 'CONTENT_TYPE' => 'application/json' } }
+
+ describe 'POST /api/authenticate' do
+ scenario 'successfully' do
+ post('/api/authenticate', params: params.to_json, headers:)
+ expect(response).to have_http_status(200)
+ expect(response.body).to include('token')
+ expect(response.body).to include('refresh')
+ end
+
+ scenario 'unsuccessfully' do
+ params[:credentials][:password] = 'wrong_password'
+ post('/api/authenticate', params: params.to_json, headers:)
+ expect(response).to have_http_status(401)
+ expect(response.body).to include('Credenciales incorrectas')
+ end
+ end
+end