From f1a92818bb0fc65c57c5dc30f06f4870c185ebaa Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Tue, 14 Mar 2023 20:20:43 -0600 Subject: Arregla specs misceláneos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../requests/sessions_controller/create_sessions_controller_spec.rb | 6 +++--- spec/requests/user_accounts_controller/show_user_accounts_spec.rb | 2 +- spec/requests/user_accounts_controller/update_user_accounts_spec.rb | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'spec/requests') diff --git a/spec/requests/sessions_controller/create_sessions_controller_spec.rb b/spec/requests/sessions_controller/create_sessions_controller_spec.rb index 69b7b42..cca04b1 100644 --- a/spec/requests/sessions_controller/create_sessions_controller_spec.rb +++ b/spec/requests/sessions_controller/create_sessions_controller_spec.rb @@ -4,13 +4,13 @@ require 'rails_helper' RSpec.describe 'POST /api/login', type: :request do it_behaves_like 'a POST request' do - let(:headers) { { 'CONTENT_TYPE' => 'application/json' } } + let(:headers) { {} } let(:route) { '/api/login' } let(:expected_error_messages) { ['Credenciales incorrectas'] } let(:desired_error_status) { 401 } let(:expected_text) { %w[token refresh] } let(:user) { create(:user_account) } - let(:params) { JSON.generate({ email: user.email, password: user.password }) } - let(:wrong_params) { JSON.generate({ email: user.email, password: 'wrong_password' }) } + let(:params) { { email: user.email, password: user.password } } + let(:wrong_params) { { email: user.email, password: 'wrong_password' } } end end diff --git a/spec/requests/user_accounts_controller/show_user_accounts_spec.rb b/spec/requests/user_accounts_controller/show_user_accounts_spec.rb index f79802a..050fda0 100644 --- a/spec/requests/user_accounts_controller/show_user_accounts_spec.rb +++ b/spec/requests/user_accounts_controller/show_user_accounts_spec.rb @@ -4,7 +4,7 @@ RSpec.describe 'GET /api/account', type: :request do let(:user) { create(:user_account) } let(:token) { jwt(user) } - it_behaves_like 'a GET request' do + it_behaves_like 'a GET resource request', sole_route: true do let(:headers) { { 'Authorization' => "Bearer #{token['token']}"} } let(:route) { '/api/account' } let(:expected_text) { [user.email, user.first_name, user.last_name, user.role] } diff --git a/spec/requests/user_accounts_controller/update_user_accounts_spec.rb b/spec/requests/user_accounts_controller/update_user_accounts_spec.rb index ba9cc69..fcfb28e 100644 --- a/spec/requests/user_accounts_controller/update_user_accounts_spec.rb +++ b/spec/requests/user_accounts_controller/update_user_accounts_spec.rb @@ -7,8 +7,7 @@ RSpec.describe 'PUT /api/account', type: :request do let(:data) { build(:user_account) } let(:token) { jwt(user) } - it_behaves_like 'a PUT request' do - let(:account) { true } + it_behaves_like 'a PUT request', account: true do let(:route) { '/api/account' } let(:headers) { { 'Authorization' => "Bearer #{token['token']}" } } let(:params) do @@ -18,7 +17,7 @@ RSpec.describe 'PUT /api/account', type: :request do let(:desired_error_status) { 422 } let(:wrong_params) { { email: 'notanemail', password: '', first_name: '', last_name: '' } } let(:expected_error_messages) do - ["Password can't be blank", 'Email is invalid', "First name can't be blank", "Last name can't be blank"] + ['Email is invalid', "First name can't be blank", "Last name can't be blank"] end end end -- cgit v1.2.3