From ea087f5bdc183b9c773979b795e366cc268aadaa Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 23 Feb 2023 18:52:38 -0600 Subject: AƱade spec del controlador de autenticaciones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/requests/authentications_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 spec/requests/authentications_spec.rb (limited to 'spec/requests') 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 -- cgit v1.2.3