diff options
author | HombreLaser <sebastian-440@live.com> | 2023-03-30 18:00:37 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2023-03-30 18:00:37 -0600 |
commit | 564203bace85c06d0de16ad5d6c2ac540642d84e (patch) | |
tree | 2fa202a85147316df065957a29126c08dc140940 /spec/requests/cards_controller/create_spec.rb | |
parent | 2ae0cd8a8dc6d630ee1a7a84ddf6111609dbdeb7 (diff) |
Añade specs de CardsController
Diffstat (limited to 'spec/requests/cards_controller/create_spec.rb')
-rw-r--r-- | spec/requests/cards_controller/create_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/requests/cards_controller/create_spec.rb b/spec/requests/cards_controller/create_spec.rb new file mode 100644 index 0000000..465288b --- /dev/null +++ b/spec/requests/cards_controller/create_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'POST /account/cards', type: :request do + let(:card) { build(:card, user_account: nil) } + let(:user) { create(:user_account, role: 'regular') } + let(:headers) { { 'Authorization' => "Bearer #{token['token']}" } } + let(:token) { jwt(user) } + let(:params) do + { number: card.number, expiration_year: card.expiration_year, expiration_month: card.expiration_month, + expiration_day: card.expiration_day, security_code: card.security_code } + end + + it_behaves_like 'a POST request' do + let(:route) { '/api/account/cards' } + let(:expected_error_messages) do + ['Number is the wrong length (should be 16 characters)', + 'Expiration year must be greater than 1970', + 'Expiration month is not included in the list', + 'Expiration day is not included in the list', + "Security code can't be blank"] + end + let(:desired_error_status) { 422 } + let(:expected_text) do + [card.number, card.expiration_year, card.expiration_month, card.expiration_day, card.security_code] + end + let(:wrong_params) do + { number: SecureRandom.hex(24), expiration_year: -20, expiration_month: 13, + expiration_day: 33, security_code: '' } + end + end +end |