rents 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rents/connection.rb +1 -1
- data/lib/rents/status.rb +2 -0
- data/lib/rents/version.rb +1 -1
- data/spec/helpers.rb +16 -0
- data/spec/rents/transaction_spec.rb +159 -58
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb3d382ab4fdcd3697a03a3724921c95520cf3d6
|
4
|
+
data.tar.gz: 127b3ba19687b1efffce1bb1984acbf73570b68a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c68fe14936da92b876cc5a8b929ffe50d7aabe6447b294f76ac63f6bb94b9dc4c0538ce90a67ef500933f6a60824f7ea434aa8fcea4f705214eb1c62917a3c63
|
7
|
+
data.tar.gz: 25519da4d3791086a14ad62d423e41a223281324e19554aeaa746b35c0165c5cead31df697b8d315ed471224b963132b9db3cc4e69810f7900c0c96289047a7b
|
data/lib/rents/connection.rb
CHANGED
data/lib/rents/status.rb
CHANGED
@@ -4,6 +4,7 @@ module Rents
|
|
4
4
|
attr_accessor :message # API response message
|
5
5
|
attr_accessor :http_code # HTTP Code for the request
|
6
6
|
attr_accessor :api_code # Internal system response code
|
7
|
+
attr_accessor :response # the JSON retrieved
|
7
8
|
|
8
9
|
# Constructor
|
9
10
|
def initialize(params = {})
|
@@ -21,6 +22,7 @@ module Rents
|
|
21
22
|
self.message = "EndPoint not response(connection error): #{self.url_requested}" if self.http_code != 200
|
22
23
|
self.message = hash_resp[:message] if self.http_code == 200
|
23
24
|
self.api_code = hash_resp[:api_code]
|
25
|
+
self.response = hash_resp
|
24
26
|
|
25
27
|
return self
|
26
28
|
end
|
data/lib/rents/version.rb
CHANGED
data/spec/helpers.rb
CHANGED
@@ -34,4 +34,20 @@ module Helpers
|
|
34
34
|
resp = RestClient.get url
|
35
35
|
JSON.parse(resp).it_keys_to_sym
|
36
36
|
end
|
37
|
+
|
38
|
+
def page_transaction_mock(card_brand, amount, redir_link)
|
39
|
+
page = {}
|
40
|
+
page[:transaction] = Rents::Transaction.new({
|
41
|
+
card:{brand: card_brand},
|
42
|
+
amount: amount, # The last 2 numbers are the cents
|
43
|
+
redirect_link: redir_link # (* optional) used only for CieloPage
|
44
|
+
})
|
45
|
+
|
46
|
+
# Fake SoldItems added
|
47
|
+
page[:transaction].sold_items = fake_sold_items
|
48
|
+
|
49
|
+
# Perform BuyPage
|
50
|
+
page[:resp] = page[:transaction].charge_page
|
51
|
+
page
|
52
|
+
end
|
37
53
|
end
|
@@ -11,75 +11,156 @@ describe Rents::Transaction do
|
|
11
11
|
context 'BuyOperatorPage' do
|
12
12
|
# OK Operator Page tests
|
13
13
|
describe '(SUCCESS REQUEST)' do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
context 'amount with cents' do
|
15
|
+
# ================ SetUp/Config ================
|
16
|
+
before(:all) do
|
17
|
+
Rents.debug=true
|
18
|
+
Rents.test_env=true
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
amount: Random.rand(99999), # The last 2 numbers are the cents
|
23
|
-
redirect_link: "#{@base_url}/api/redirect_receiver" # (* optional) used only for CieloPage
|
24
|
-
})
|
20
|
+
# "Int" amount, with cents
|
21
|
+
amount = (BigDecimal Random.rand(99999))/100
|
22
|
+
card_brand = 'elo'
|
25
23
|
|
26
|
-
|
27
|
-
|
24
|
+
# (* optional) used only for CieloPage
|
25
|
+
redir_link = "#{@base_url}/api/redirect_receiver"
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
# With cents
|
28
|
+
aux = page_transaction_mock(card_brand, amount, redir_link)
|
29
|
+
@page_resp = aux[:resp]
|
30
|
+
@page_transaction = aux[:transaction]
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
# ================ Tests/Expects/Should ================
|
34
|
+
it 'resp should not be null' do
|
35
|
+
expect(@page_resp).to_not be_nil
|
36
|
+
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
it 'resp should contain the RequestID' do
|
39
|
+
request_id = @page_resp[:request_id]
|
40
|
+
expect(request_id).to_not be_nil
|
41
|
+
expect(request_id).to be_a Integer
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
it 'should setup the rid accessible method' do
|
45
|
+
expect(@page_transaction.rid).to_not be_nil
|
46
|
+
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
it 'should setup the purchase_url accessible method' do
|
49
|
+
expect(@page_transaction.purchase_url).to_not be_nil
|
50
|
+
end
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
it 'resp should not have any error' do
|
53
|
+
error = @page_resp[:error]
|
54
|
+
error = @page_resp['error'] if error.nil?
|
55
|
+
expect(error).to be_nil
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
58
|
+
it 'resp should be an accessible Operator URL' do
|
59
|
+
url = @page_transaction.purchase_url
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
expect(url).to_not be_nil
|
62
|
+
expect(accessible?(url)).to be_truthy
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'must be verifiable' do
|
66
|
+
# SetUps
|
67
|
+
verify_resp = @page_transaction.verify
|
68
|
+
error = verify_resp[:error]
|
69
|
+
error = verify_resp['error'] if error.nil?
|
64
70
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
error = verify_resp[:error]
|
69
|
-
error = verify_resp['error'] if error.nil?
|
71
|
+
# Validations
|
72
|
+
expect(error).to be_nil
|
73
|
+
expect(verify_resp).to_not be_nil
|
70
74
|
|
71
|
-
|
72
|
-
|
73
|
-
|
75
|
+
# It is just created status
|
76
|
+
expect(0..1).to cover(verify_resp[:status][:code])
|
77
|
+
expect(verify_resp[:status][:name]).to eq('pending')
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'must have a get accessible URL request' do
|
81
|
+
url = @page_transaction.url_requested+@page_transaction.request_params.it_keys_to_get_param
|
82
|
+
expect(be_accessible(url)).to be_truthy
|
83
|
+
end
|
74
84
|
|
75
|
-
|
76
|
-
|
77
|
-
|
85
|
+
it 'amount must be the same as send' do
|
86
|
+
expect(@page_transaction.amount.to_i).to be == @page_resp[:transaction][:amount]
|
87
|
+
end
|
78
88
|
end
|
79
89
|
|
80
|
-
|
81
|
-
|
82
|
-
|
90
|
+
context 'full amount (without any cent)' do
|
91
|
+
# ================ SetUp/Config ================
|
92
|
+
before(:all) do
|
93
|
+
Rents.debug=true
|
94
|
+
Rents.test_env=true
|
95
|
+
|
96
|
+
# "Int" amount, no cents
|
97
|
+
amount = BigDecimal Random.rand(99999)
|
98
|
+
card_brand = 'visa'
|
99
|
+
|
100
|
+
# (* optional) used only for CieloPage
|
101
|
+
redir_link = "#{@base_url}/api/redirect_receiver"
|
102
|
+
|
103
|
+
# Without cents ,00
|
104
|
+
aux = page_transaction_mock(card_brand, amount, redir_link)
|
105
|
+
@page_resp = aux[:resp]
|
106
|
+
@page_transaction = aux[:transaction]
|
107
|
+
end
|
108
|
+
|
109
|
+
# ================ Tests/Expects/Should ================
|
110
|
+
it 'resp should not be null' do
|
111
|
+
expect(@page_resp).to_not be_nil
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'resp should contain the RequestID' do
|
115
|
+
request_id = @page_resp[:request_id]
|
116
|
+
expect(request_id).to_not be_nil
|
117
|
+
expect(request_id).to be_a Integer
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should setup the rid accessible method' do
|
121
|
+
expect(@page_transaction.rid).to_not be_nil
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should setup the purchase_url accessible method' do
|
125
|
+
expect(@page_transaction.purchase_url).to_not be_nil
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'resp should not have any error' do
|
129
|
+
error = @page_resp[:error]
|
130
|
+
error = @page_resp['error'] if error.nil?
|
131
|
+
expect(error).to be_nil
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'resp should be an accessible Operator URL' do
|
135
|
+
url = @page_transaction.purchase_url
|
136
|
+
|
137
|
+
expect(url).to_not be_nil
|
138
|
+
expect(accessible?(url)).to be_truthy
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'must be verifiable' do
|
142
|
+
# SetUps
|
143
|
+
verify_resp = @page_transaction.verify
|
144
|
+
error = verify_resp[:error]
|
145
|
+
error = verify_resp['error'] if error.nil?
|
146
|
+
|
147
|
+
# Validations
|
148
|
+
expect(error).to be_nil
|
149
|
+
expect(verify_resp).to_not be_nil
|
150
|
+
|
151
|
+
# It is just created status
|
152
|
+
expect(0..1).to cover(verify_resp[:status][:code])
|
153
|
+
expect(verify_resp[:status][:name]).to eq('pending')
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'must have a get accessible URL request' do
|
157
|
+
url = @page_transaction.url_requested+@page_transaction.request_params.it_keys_to_get_param
|
158
|
+
expect(be_accessible(url)).to be_truthy
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'amount must be the same as send' do
|
162
|
+
expect(@page_transaction.amount.to_i).to be == @page_resp[:transaction][:amount]
|
163
|
+
end
|
83
164
|
end
|
84
165
|
end
|
85
166
|
|
@@ -358,7 +439,7 @@ describe Rents::Transaction do
|
|
358
439
|
# SetUpVars
|
359
440
|
empty_subscription_resp = @empty_transaction_resp[:subscription]
|
360
441
|
resp_amount = empty_subscription_resp[:amount]
|
361
|
-
resp_recurrence_period = empty_subscription_resp[:
|
442
|
+
resp_recurrence_period = empty_subscription_resp[:recurrence_period]
|
362
443
|
|
363
444
|
# test those attrs
|
364
445
|
expect(resp_amount).to eq(@amount)
|
@@ -367,7 +448,7 @@ describe Rents::Transaction do
|
|
367
448
|
# SetUpVars
|
368
449
|
rid_subscription_resp = @rid_transaction_resp[:subscription]
|
369
450
|
resp_amount = rid_subscription_resp[:amount]
|
370
|
-
resp_recurrence_period = rid_subscription_resp[:
|
451
|
+
resp_recurrence_period = rid_subscription_resp[:recurrence_period]
|
371
452
|
|
372
453
|
# test those attrs
|
373
454
|
expect(resp_amount).to eq(@amount)
|
@@ -547,7 +628,7 @@ describe Rents::Transaction do
|
|
547
628
|
describe 'Update recurrent subscription DENIED' do
|
548
629
|
# ================ SetUp/Config ================
|
549
630
|
before(:all) do
|
550
|
-
Rents.debug=
|
631
|
+
Rents.debug=true
|
551
632
|
Rents.test_env=false
|
552
633
|
|
553
634
|
Rents.app_id = 1
|
@@ -585,7 +666,7 @@ describe Rents::Transaction do
|
|
585
666
|
describe 'Unsubscribe denied' do
|
586
667
|
# ================ SetUp/Config ================
|
587
668
|
before(:all) do
|
588
|
-
Rents.debug=
|
669
|
+
Rents.debug=true
|
589
670
|
Rents.test_env=false
|
590
671
|
|
591
672
|
Rents.app_id = 1
|
@@ -677,4 +758,24 @@ describe Rents::Transaction do
|
|
677
758
|
comment_proxy_yml
|
678
759
|
end
|
679
760
|
end
|
761
|
+
|
762
|
+
context 'Remote sample connection test' do
|
763
|
+
before(:all) do
|
764
|
+
Rents.debug=false
|
765
|
+
Rents.test_env=false
|
766
|
+
@remote = Rents::Status.new
|
767
|
+
end
|
768
|
+
|
769
|
+
it 'must have a response JSON' do
|
770
|
+
expect(@remote.response).to be_a Hash
|
771
|
+
end
|
772
|
+
|
773
|
+
it 'must have a message' do
|
774
|
+
expect(@remote.message).to be_a String
|
775
|
+
end
|
776
|
+
|
777
|
+
it 'must have an API code' do
|
778
|
+
expect(@remote.api_code).to be_a Integer
|
779
|
+
end
|
780
|
+
end
|
680
781
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rents
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilton Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|