1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'POST /api/user_accounts', type: :request do
let(:user) { build(:user_account) }
let(:route) { '/api/user_accounts' }
let(:params) do
{ email: user.email, password: user.password,
first_name: user.first_name, last_name: user.last_name }
end
it_behaves_like 'a POST request' do
let(:headers) { {} }
let(:expected_error_messages) do
["can't be blank", 'is invalid', "can't be blank", "can't be blank"]
end
let(:desired_error_status) { 422 }
let(:expected_text) { %w[token refresh] }
let(:params) do
{ email: user.email, password: user.password,
first_name: user.first_name, last_name: user.last_name }
end
let(:wrong_params) { { email: 'notanemail', password: '', first_name: '', last_name: '' } }
end
context 'after creating a user' do
it 'should create a cart belonging to him' do
post(route, params:)
created_user = UserAccount.find_by(email: user.email)
expect { Cart.find(created_user.cart_id) }.not_to raise_error
2 + 2
end
end
end
|