webpay-mock 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webpay/mock/fake_entity/charge.rb +1 -1
- data/lib/webpay/mock/fake_error.rb +19 -12
- data/lib/webpay/mock/version.rb +1 -1
- data/lib/webpay/mock/webmock_wrapper.rb +2 -0
- data/lib/webpay/mock.rb +0 -1
- data/spec/fake_entity/charge_spec.rb +1 -1
- data/spec/fake_entity_spec.rb +12 -0
- data/spec/webmock_wrapper_spec.rb +10 -0
- 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: eb0dd9999cc3d3dc74d84f7f0c612fafe45db3ab
|
4
|
+
data.tar.gz: e50c6b8cc4f2bfd9b7f3d4491cf4efbf53a4683f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f599f77b6251d9d4eb19f79f644a95bace9316f0b383b9b566087777c6c0244e0b09db25e16edfac9f4c1c5ab6b4886e025517434d62d7ca11c49c8dcda5d027
|
7
|
+
data.tar.gz: 4fe76762f6aec970f48467701a48ea7a3c952ad5cd68d577ce0900d025a7c5909273547eba4d55e48972a1aa1dc182682afbf46f82f13abac9ac0c1ae430c2ac
|
@@ -5,9 +5,10 @@ module WebPay::Mock::FakeError
|
|
5
5
|
{
|
6
6
|
status: 400,
|
7
7
|
body: { error: {
|
8
|
-
'
|
9
|
-
'
|
10
|
-
'param'
|
8
|
+
'message' => 'Missing required param: amount',
|
9
|
+
'caused_by' => 'insufficient',
|
10
|
+
'param' => 'amount',
|
11
|
+
'type' => 'invalid_request_error'
|
11
12
|
}.merge(stringify_keys(overrides)) }.to_json
|
12
13
|
}
|
13
14
|
end
|
@@ -16,7 +17,9 @@ module WebPay::Mock::FakeError
|
|
16
17
|
{
|
17
18
|
status: 401,
|
18
19
|
body: { error: {
|
19
|
-
'message'
|
20
|
+
'message' => "You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY').",
|
21
|
+
'caused_by' => 'insufficient',
|
22
|
+
'type' => 'unauthorized'
|
20
23
|
}.merge(stringify_keys(overrides)) }.to_json
|
21
24
|
}
|
22
25
|
end
|
@@ -25,9 +28,11 @@ module WebPay::Mock::FakeError
|
|
25
28
|
{
|
26
29
|
status: 402,
|
27
30
|
body: { error: {
|
28
|
-
'
|
29
|
-
'
|
30
|
-
'
|
31
|
+
'message' => 'The card number is invalid. Make sure the number entered matches your credit card.',
|
32
|
+
'caused_by' => 'buyer',
|
33
|
+
'param' => 'number',
|
34
|
+
'type' => 'card_error',
|
35
|
+
'code' => 'incorrect_number'
|
31
36
|
}.merge(stringify_keys(overrides)) }.to_json
|
32
37
|
}
|
33
38
|
end
|
@@ -36,9 +41,10 @@ module WebPay::Mock::FakeError
|
|
36
41
|
{
|
37
42
|
status: 404,
|
38
43
|
body: { error: {
|
39
|
-
'
|
40
|
-
'
|
41
|
-
'param'
|
44
|
+
'message' => 'No such charge',
|
45
|
+
'caused_by' => 'missing',
|
46
|
+
'param' => 'id',
|
47
|
+
'type' => 'invalid_request_error'
|
42
48
|
}.merge(stringify_keys(overrides)) }.to_json
|
43
49
|
}
|
44
50
|
end
|
@@ -47,8 +53,9 @@ module WebPay::Mock::FakeError
|
|
47
53
|
{
|
48
54
|
status: 500,
|
49
55
|
body: { error: {
|
50
|
-
'type'
|
51
|
-
'message'
|
56
|
+
'type' => 'api_error',
|
57
|
+
'message' => 'Unkown error occured',
|
58
|
+
'caused_by' => 'service'
|
52
59
|
}.merge(stringify_keys(overrides)) }.to_json
|
53
60
|
}
|
54
61
|
end
|
data/lib/webpay/mock/version.rb
CHANGED
@@ -57,6 +57,8 @@ module WebPay::Mock::WebMockWrapper
|
|
57
57
|
[:delete, '/customers/:id', { 'id' => id, 'deleted' => true }]
|
58
58
|
when :all
|
59
59
|
[:get, '/customers', fake_list('/customers', lambda { customer_from({}, overrides) })]
|
60
|
+
when :delete_active_card
|
61
|
+
[:delete, '/customers/:id/active_card',customer_from({}, { id: id }.merge(overrides.merge(active_card: nil)))]
|
60
62
|
end
|
61
63
|
when :recursion, :recursions
|
62
64
|
case action.to_sym
|
data/lib/webpay/mock.rb
CHANGED
@@ -69,7 +69,7 @@ describe WebPay::Mock::FakeEntity::Charge do
|
|
69
69
|
subject(:charge) { charge_from(capture: false) }
|
70
70
|
|
71
71
|
specify { expect(charge['captured']).to eq false }
|
72
|
-
specify { expect(charge['paid']).to eq
|
72
|
+
specify { expect(charge['paid']).to eq true }
|
73
73
|
specify { expect(charge['expire_time']).to be_within(2).of(Time.now.to_i + 60 * 60 * 24 * 7) }
|
74
74
|
end
|
75
75
|
|
data/spec/fake_entity_spec.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'webpay'
|
3
|
+
|
2
4
|
describe WebPay::Mock::FakeEntity do
|
3
5
|
include WebPay::Mock::FakeEntity
|
4
6
|
|
@@ -9,4 +11,14 @@ describe WebPay::Mock::FakeEntity do
|
|
9
11
|
specify { expect(list['count']).to eq 3 }
|
10
12
|
specify { expect(list['data']).to eq [1, 2, 3] }
|
11
13
|
end
|
14
|
+
|
15
|
+
describe 'fake webhook request from event' do
|
16
|
+
let(:webpay) { WebPay.new('test_secret_xxxxxx') }
|
17
|
+
|
18
|
+
it 'should accept string event as webhook body' do
|
19
|
+
fake = fake_event
|
20
|
+
received = webpay.receive_webhook(fake.to_json)
|
21
|
+
expect(received.id).to eq fake['id']
|
22
|
+
end
|
23
|
+
end
|
12
24
|
end
|
@@ -106,6 +106,16 @@ describe WebPay::Mock::WebMockWrapper do
|
|
106
106
|
before { webpay_stub(:customers, :all) }
|
107
107
|
specify { expect(webpay.customer.all.count).to eq 3 }
|
108
108
|
end
|
109
|
+
|
110
|
+
describe 'delete_active_card' do
|
111
|
+
let(:id) { 'cus_xxxxxxxxx' }
|
112
|
+
let!(:updated) { webpay_stub(:customers, :delete_active_card, id: id) }
|
113
|
+
specify do
|
114
|
+
response = webpay.customer.delete_active_card(id: id)
|
115
|
+
expect(response.id).to eq id
|
116
|
+
expect(response.active_card).to be_nil
|
117
|
+
end
|
118
|
+
end
|
109
119
|
end
|
110
120
|
|
111
121
|
describe 'recursios' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webpay-mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- webpay
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: webmock
|