stp_client 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/stp/account.rb +3 -3
- data/lib/stp/version.rb +1 -1
- data/spec/stp/account_create_spec.rb +35 -1
- data/spec/stp/payment_order_spec.rb +1 -1
- data/spec/support/stp_test_helpers.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '05976db95cd7be28ef2d13164508e7d5c745c4e2ca3b8f35b1f9241948410e22'
|
4
|
+
data.tar.gz: 927bea6de224a93188c78ccdd7cacd477fbe58fe17a3cdfc8dfba18119387b8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d35b0e8528f1534f3c903097c06b3442f93f4d0ae4836605a8e7f66fe5a4e3ed77c8d9a662fbf86bab5eb758539de30381d58852c737e81784cd59495692110f
|
7
|
+
data.tar.gz: e16c3fb810252149388304a5cabe36b2e48314c49646a3245094bc78c57e36ad7ce4b6fef345bd9778ab3414ba25ef29111b9f92d76e897f0ae5c056f9534deb
|
data/Gemfile.lock
CHANGED
data/lib/stp/account.rb
CHANGED
@@ -10,8 +10,8 @@ module STP
|
|
10
10
|
end
|
11
11
|
puts response.body if STP.verbose
|
12
12
|
hash = JSON.parse(response.body)
|
13
|
-
raise STP::Errors::AccountAlreadyExists.new(hash['id'], hash['
|
14
|
-
raise STP::Errors::STPError.new(hash['id'], hash['
|
13
|
+
raise STP::Errors::AccountAlreadyExists.new(hash['id'], hash['descripcion']) if hash['id'] == 1 && hash['descripcion'] == 'Cuenta Duplicada'
|
14
|
+
raise STP::Errors::STPError.new(hash['id'], hash['descripcion']) unless hash['id'] == 0
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.delete(account)
|
@@ -24,7 +24,7 @@ module STP
|
|
24
24
|
end
|
25
25
|
puts response.body if STP.verbose
|
26
26
|
hash = JSON.parse(response.body)
|
27
|
-
raise STP::Errors::STPError.new(hash['id'], hash['
|
27
|
+
raise STP::Errors::STPError.new(hash['id'], hash['descripcion']) unless hash['id'] == 0
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/lib/stp/version.rb
CHANGED
@@ -61,7 +61,7 @@ RSpec.describe STP::Account do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
context 'fails when' do
|
64
|
-
context '
|
64
|
+
context 'random error' do
|
65
65
|
let(:account_obj) do
|
66
66
|
account = STP::Structs::Account.new
|
67
67
|
account.account = '01010101'
|
@@ -94,6 +94,40 @@ RSpec.describe STP::Account do
|
|
94
94
|
|
95
95
|
it { expect {subject}.to raise_error(STP::Errors::STPError) }
|
96
96
|
end
|
97
|
+
|
98
|
+
context 'repeating account and rfcCurp' do
|
99
|
+
let(:account_obj) do
|
100
|
+
account = STP::Structs::Account.new
|
101
|
+
account.account = '01010101'
|
102
|
+
account.name = Faker::Name.first_name
|
103
|
+
account.paternal_surname = Faker::Name.last_name
|
104
|
+
account.maternal_surname = Faker::Name.last_name
|
105
|
+
account.rfc = 'RFC'
|
106
|
+
account.birthdate = Faker::Date.birthday(min_age: 6, max_age: 65)
|
107
|
+
account.sex = 'male'
|
108
|
+
account.state = 'Mérida'
|
109
|
+
account.economic_activity = 'programador'
|
110
|
+
account.street = Faker::Address.street_name
|
111
|
+
account.exterior_number = Faker::Address.building_number
|
112
|
+
account.interior_nunmber = Faker::Address.building_number
|
113
|
+
account.neighborhood = Faker::Address.community
|
114
|
+
account.municipality = Faker::Address.community
|
115
|
+
account.zip_code = Faker::Number.number(digits: 5)
|
116
|
+
account.country = 'México'
|
117
|
+
account.email = Faker::Internet.email
|
118
|
+
account.identification_id = 'id'
|
119
|
+
account.phone = Faker::PhoneNumber.phone_number
|
120
|
+
account
|
121
|
+
end
|
122
|
+
|
123
|
+
before do
|
124
|
+
stub_request(:put, "#{STP.api_uri}/cuentaModule/fisica").to_return(
|
125
|
+
body: JSON.dump(STPTestHelpers::ACCOUNT_CREATE_MOCK_ERROR(1, 'Cuenta Duplicada')), status: 200
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
129
|
+
it { expect {subject}.to raise_error(STP::Errors::AccountAlreadyExists) }
|
130
|
+
end
|
97
131
|
end
|
98
132
|
end
|
99
133
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module STPTestHelpers
|
2
2
|
def self.PAYMENT_ORDER_MOCK_ERROR(error_code)
|
3
3
|
{
|
4
|
-
'
|
4
|
+
'descripcion' => 'regular error msg',
|
5
5
|
'id' => error_code,
|
6
6
|
}
|
7
7
|
end
|
@@ -16,9 +16,9 @@ module STPTestHelpers
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.ACCOUNT_CREATE_MOCK_ERROR(error_code)
|
19
|
+
def self.ACCOUNT_CREATE_MOCK_ERROR(error_code, message='regular error msg')
|
20
20
|
{
|
21
|
-
'
|
21
|
+
'descripcion' => message,
|
22
22
|
'id' => error_code,
|
23
23
|
}
|
24
24
|
end
|
@@ -32,7 +32,7 @@ module STPTestHelpers
|
|
32
32
|
|
33
33
|
def self.ACCOUNT_DELETE_MOCK_ERROR(error_code)
|
34
34
|
{
|
35
|
-
'
|
35
|
+
'descripcion' => 'regular error msg',
|
36
36
|
'id' => error_code,
|
37
37
|
}
|
38
38
|
end
|