summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-02-24 21:29:13 -0600
committerHombreLaser <sebastian-440@live.com>2023-02-24 21:29:13 -0600
commitf758b80b4818fd98753167366191b203cdab306a (patch)
tree112dc9b620aeefc654763f8d42d42c34f1cc1fac /spec/requests
parent53c55cbf14899d83023cf2e9b11ed204e7b630d3 (diff)
Refactoriza el suite de tests
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/authentications_spec.rb28
1 files changed, 9 insertions, 19 deletions
diff --git a/spec/requests/authentications_spec.rb b/spec/requests/authentications_spec.rb
index 2ee8ead..71ffa19 100644
--- a/spec/requests/authentications_spec.rb
+++ b/spec/requests/authentications_spec.rb
@@ -2,24 +2,14 @@
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
+RSpec.describe 'POST /api/authenticate', type: :request do
+ it_behaves_like 'a POST request' do
+ let(:route) { '/api/authenticate' }
+ let(:expected_error_message) { 'Credenciales incorrectas' }
+ let(:desired_error_status) { 401 }
+ let(:expected_text) { %w[token refresh] }
+ let(:user) { create(:user_account) }
+ let(:params) { { credentials: { email: user.email, password: user.password } } }
+ let(:wrong_params) { { credentials: { email: user.email, password: 'wrong_password' } } }
end
end