stripe-ruby-mock 1.8.3.1 → 1.8.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +19 -2
- data/lib/stripe_mock/data.rb +7 -0
- data/lib/stripe_mock/request_handlers/customers.rb +9 -4
- data/lib/stripe_mock/version.rb +1 -1
- data/spec/readme_spec.rb +13 -0
- data/spec/stripe/customer_spec.rb +7 -0
- metadata +2 -2
data/README.md
CHANGED
@@ -45,7 +45,7 @@ end
|
|
45
45
|
|
46
46
|
## Mocking Errors
|
47
47
|
|
48
|
-
Tired of manually inputting fake credit card numbers to test against errors?
|
48
|
+
Tired of manually inputting fake credit card numbers to test against errors? Tire no longer!
|
49
49
|
|
50
50
|
```ruby
|
51
51
|
it "mocks a declined card error" do
|
@@ -79,11 +79,28 @@ it "raises a custom error" do
|
|
79
79
|
end
|
80
80
|
```
|
81
81
|
|
82
|
+
### Built-In Card Errors
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
StripeMock.prepare_card_error(:incorrect_number)
|
86
|
+
StripeMock.prepare_card_error(:invalid_number)
|
87
|
+
StripeMock.prepare_card_error(:invalid_expiry_month)
|
88
|
+
StripeMock.prepare_card_error(:invalid_expiry_year)
|
89
|
+
StripeMock.prepare_card_error(:invalid_cvc)
|
90
|
+
StripeMock.prepare_card_error(:expired_card)
|
91
|
+
StripeMock.prepare_card_error(:incorrect_cvc)
|
92
|
+
StripeMock.prepare_card_error(:card_declined)
|
93
|
+
StripeMock.prepare_card_error(:missing)
|
94
|
+
StripeMock.prepare_card_error(:processing_error)
|
95
|
+
```
|
96
|
+
|
97
|
+
You can see the details of each error in [lib/stripe_mock/api/errors.rb](lib/stripe_mock/api/errors.rb)
|
98
|
+
|
82
99
|
## TODO
|
83
100
|
|
84
101
|
* Cover all stripe urls/methods
|
85
102
|
* Create hash for storing/retrieving all stripe objects in-memory
|
86
|
-
* Currently implemented for: **Customers** and **
|
103
|
+
* Currently implemented for: **Customers**, **Charges**, and **Plans**
|
87
104
|
|
88
105
|
## Copyright
|
89
106
|
|
data/lib/stripe_mock/data.rb
CHANGED
@@ -3,10 +3,11 @@ module StripeMock
|
|
3
3
|
module Customers
|
4
4
|
|
5
5
|
def Customers.included(klass)
|
6
|
-
klass.add_handler 'post /v1/customers',
|
7
|
-
klass.add_handler 'post /v1/customers/(.*)/subscription',
|
8
|
-
klass.add_handler '
|
9
|
-
klass.add_handler '
|
6
|
+
klass.add_handler 'post /v1/customers', :new_customer
|
7
|
+
klass.add_handler 'post /v1/customers/(.*)/subscription', :new_subscription
|
8
|
+
klass.add_handler 'delete /v1/customers/(.*)/subscription', :cancel_subscription
|
9
|
+
klass.add_handler 'post /v1/customers/(.*)', :update_customer
|
10
|
+
klass.add_handler 'get /v1/customers/(.*)', :get_customer
|
10
11
|
end
|
11
12
|
|
12
13
|
def new_customer(route, method_url, params, headers)
|
@@ -18,6 +19,10 @@ module StripeMock
|
|
18
19
|
Data.test_subscription(params[:plan])
|
19
20
|
end
|
20
21
|
|
22
|
+
def cancel_subscription(route, method_url, params, headers)
|
23
|
+
Data.test_delete_subscription(params[:id])
|
24
|
+
end
|
25
|
+
|
21
26
|
def update_customer(route, method_url, params, headers)
|
22
27
|
route =~ method_url
|
23
28
|
customers[$1] ||= Data.test_customer(:id => $1)
|
data/lib/stripe_mock/version.rb
CHANGED
data/spec/readme_spec.rb
CHANGED
@@ -42,4 +42,17 @@ describe 'README examples' do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
it "has built-in card errors" do
|
46
|
+
StripeMock.prepare_card_error(:incorrect_number)
|
47
|
+
StripeMock.prepare_card_error(:invalid_number)
|
48
|
+
StripeMock.prepare_card_error(:invalid_expiry_month)
|
49
|
+
StripeMock.prepare_card_error(:invalid_expiry_year)
|
50
|
+
StripeMock.prepare_card_error(:invalid_cvc)
|
51
|
+
StripeMock.prepare_card_error(:expired_card)
|
52
|
+
StripeMock.prepare_card_error(:incorrect_cvc)
|
53
|
+
StripeMock.prepare_card_error(:card_declined)
|
54
|
+
StripeMock.prepare_card_error(:missing)
|
55
|
+
StripeMock.prepare_card_error(:processing_error)
|
56
|
+
end
|
57
|
+
|
45
58
|
end
|
@@ -73,4 +73,11 @@ describe 'Customer API' do
|
|
73
73
|
expect(sub.plan.id).to eq('silver')
|
74
74
|
end
|
75
75
|
|
76
|
+
it "cancels a stripe customer's subscription" do
|
77
|
+
customer = Stripe::Customer.retrieve("test_customer_sub")
|
78
|
+
sub = customer.cancel_subscription
|
79
|
+
|
80
|
+
expect(sub.deleted).to eq(true)
|
81
|
+
end
|
82
|
+
|
76
83
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe-ruby-mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.3.
|
4
|
+
version: 1.8.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: stripe
|