rents 0.1.11 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc66982b33b6896de1c0ada00b9c6fc4424fdd2d
4
- data.tar.gz: 14b03265092a30798e55287a9612b94345d1afe5
3
+ metadata.gz: e06c58eb1321502e8141b471a5aba0b782406cb4
4
+ data.tar.gz: 338f971e9e496295b298b6178d801b37139c7d08
5
5
  SHA512:
6
- metadata.gz: 742ab0dde2c083aa268a11b8ae4ec4445c8accf4251800c518d9093b1a14a138d2c7b483c8dce4931d1b3206f046a38581709ffaee31349d9a3d2f7c26037eaa
7
- data.tar.gz: d3d47cf27a9e15eb4c5125059da323bb38b081a711e4d19c873e34eed02d48a2ebaef3e1f1921b50d89925eb1764d6370d823b3c15c6c1bfdf41f19529456e1c
6
+ metadata.gz: 73c6a89696092ab521a65ffd26b054120748df24b49dd59d769a4b76146547ac58f7011eb7da059b7540194d47e87b7ff2a2610f6d724036416d26cc32413798
7
+ data.tar.gz: 510f56ab6d54b8a9292743759ca2e6c4398da68866ffb0ca9dfea7c057e80e5457884c6f0ac60368fbec348ab40f1abefaa3d1a430d59ea25cc6e9dd204bae60
data/lib/rents/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Rents
2
- MAJOR = 0
3
- MINOR = 1
4
- PATCH = 11
2
+ MAJOR = 1
3
+ MINOR = 0
4
+ PATCH = 0
5
5
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
6
6
  end
@@ -135,6 +135,28 @@ describe Rents::Transaction do
135
135
  it 'resp should not be null' do
136
136
  expect(@resp).to_not be_nil
137
137
  end
138
+
139
+ it 'resp should have a full SUCCESSFUL transaction status' do
140
+ status = @resp[:status]
141
+ expect(status[:name]).to eq('charged')
142
+ expect(status[:code]).to eq(6) # TODO change it to ENUM
143
+ expect(status[:msg].index('Capturada').nil?).to_not be_truthy
144
+ end
145
+
146
+ it 'resp should have a full CardObj which is allowed to be stored {:rid, :truncated, :flag}' do
147
+ card = @resp[:card]
148
+ expect(card[:rid]).to be_a Integer
149
+ expect(card[:rid] == 0).to_not be_truthy
150
+ expect(card[:brand_mark]).to eq('visa')
151
+ expect(card[:truncated].index('***')).to_not be_nil
152
+ end
153
+
154
+ it 'resp should have the remote reference (TransactionRID)' do
155
+ rid = @resp[:rid]
156
+ expect(rid).to_not be_nil
157
+ expect(rid).to be_a Integer
158
+ expect(rid != 0).to be_truthy
159
+ end
138
160
  end
139
161
 
140
162
  # TRANSACTION DENIED example
@@ -149,16 +171,16 @@ describe Rents::Transaction do
149
171
  amount = "#{amount}71" if amount[amount.length-2, amount.length] == '00'
150
172
 
151
173
  @store_transaction = Rents::Transaction.new({
152
- card:{
153
- flag: 'visa',
154
- cvv: '123',
155
- expiration_month: '05',
156
- expiration_year: '2018',
157
- number: '9999999999999999',
158
- holder: Faker::Name.name,
159
- },
160
-
161
- amount: amount
174
+ card:{
175
+ flag: 'visa',
176
+ cvv: '321',
177
+ expiration_month: '05',
178
+ expiration_year: '2018',
179
+ number: '9999999999999999',
180
+ holder: Faker::Name.name,
181
+ },
182
+
183
+ amount: amount
162
184
  })
163
185
 
164
186
  # Fake SoldItems added
@@ -173,65 +195,71 @@ describe Rents::Transaction do
173
195
  expect(@resp).to_not be_nil
174
196
  end
175
197
 
176
- it 'should setup the rid accessible method' do
177
- expect(@resp[:rid]).to_not be_nil
178
- end
179
-
180
- it 'should setup the purchase_url accessible method' do
181
- expect(@resp.purchase_url).to_not be_nil
198
+ it 'resp should have a full SUCCESSFUL transaction status' do
199
+ status = @resp[:status]
200
+ expect(status[:name]).to eq('error')
201
+ expect(status[:code]).to eq(5) # TODO change it to ENUM
202
+ expect(status[:msg].index('não').nil?).to_not be_truthy
182
203
  end
183
204
 
184
- it 'resp should not have any error' do
185
- error = @resp[:error]
186
- error = @resp['error'] if error.nil?
187
- expect(error).to be_nil
205
+ it 'resp should have a full CardObj which is allowed to be stored {:rid, :truncated, :flag}' do
206
+ card = @resp[:card]
207
+ expect(card[:rid]).to be_nil
208
+ expect(card[:brand_mark]).to eq('visa')
209
+ expect(card[:truncated].index('***')).to_not be_nil
188
210
  end
189
211
 
190
- it 'resp should be an accessible Operator URL' do
191
- url = @page_transaction.purchase_url
192
-
193
- expect(url).to_not be_nil
194
- expect(accessible?(url)).to be_truthy
195
- end
196
-
197
- it 'must be verifiable' do
198
- # SetUps
199
- verify_resp = @page_transaction.verify
200
- error = verify_resp[:error]
201
- error = verify_resp['error'] if error.nil?
202
-
203
- # Validations
204
- expect(verify_resp).to_not be_nil
205
- expect(error).to be_nil
206
- end
207
-
208
- it 'must have a get accessible URL request' do
209
- url = @page_transaction.url_requested+@page_transaction.request_params.it_keys_to_get_param
210
- expect(be_accessible(url)).to be_truthy
212
+ it 'resp should have the remote reference (TransactionRID)' do
213
+ rid = @resp[:rid]
214
+ expect(rid).to_not be_nil
215
+ expect(rid).to be_a Integer
216
+ expect(rid != 0).to be_truthy
211
217
  end
212
218
  end
213
219
 
214
220
  # NOT_OK on the authentication Store Page tests
215
221
  describe '(BAD REQUEST) Store - BuyPage' do
216
222
  # SetUp/Config
217
- before(:each) do
223
+ before(:all) do
218
224
  Rents.test_env = false
219
225
  Rents.debugger = false
220
226
  Rents.app_id = 1
221
227
  Rents.secret_key = '12312321312$2a$10$NmV9EysKVLe8ItBdl9CHN.LF05bOuDdoOkmfptdbJs7cuaDWksuUu'
222
- base_url = 'http://localhost:7000'
223
228
 
224
- # Not using test_env (so using a app passed not the global app)
225
- @page_transaction = Rents::Transaction.new({
226
- card:{flag:'visa'},
227
- amount: Random.rand(99999), # TODO: no error por rand menor que 99 (* mandatory) Amount in cents (1000 = R$ 10,00)
228
- redirect_link: "#{base_url}/api/redirect_receiver" # (* optional) used only for CieloPage
229
+ amount = Random.rand(99999).to_s
230
+ amount = "#{amount}00" if amount[amount.length-2, amount.length] != '00'
231
+
232
+ @store_transaction = Rents::Transaction.new({
233
+ card:{
234
+ flag: 'visa',
235
+ cvv: '321',
236
+ expiration_month: '05',
237
+ expiration_year: '2018',
238
+ number: '9999999999999999',
239
+ holder: Faker::Name.name,
240
+ },
241
+
242
+ amount: amount
229
243
  })
230
244
 
231
- # Send BuyPage
232
- @page_resp = @page_transaction.charge_page(full_resp=true)
245
+ # Fake SoldItems added
246
+ @store_transaction.sold_items = fake_sold_items
247
+
248
+ # Send StoreCharge
249
+ @resp = @store_transaction.charge_store
233
250
  end
234
251
 
235
252
  # ================ Tests/Expects/Should ================
253
+ it 'resp should exist (do not be empty)' do
254
+ expect(@resp).to_not be_nil
255
+ end
256
+
257
+ it 'resp should contain auth error' do
258
+ error = @resp[:error].downcase
259
+ expect(error).to_not be_nil
260
+ expect(error.index('auth error').nil?).to_not be_truthy
261
+ expect(error.index('AppID'.downcase).nil?).to_not be_truthy
262
+ expect(error.index('SecretKey'.downcase).nil?).to_not be_truthy
263
+ end
236
264
  end
237
265
  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: 0.1.11
4
+ version: 1.0.0
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-01-23 00:00:00.000000000 Z
11
+ date: 2015-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler