stripe-ruby-mock 1.8.4.7 → 1.8.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md
CHANGED
data/lib/stripe_mock/instance.rb
CHANGED
@@ -42,20 +42,20 @@ module StripeMock
|
|
42
42
|
# Ensure params hash has symbols as keys
|
43
43
|
params = Stripe::Util.symbolize_names(params)
|
44
44
|
|
45
|
-
if @debug == true
|
46
|
-
puts "[StripeMock req] #{method} #{url}"
|
47
|
-
puts " #{params}"
|
48
|
-
end
|
49
|
-
|
50
45
|
method_url = "#{method} #{url}"
|
51
46
|
|
52
47
|
if handler = Instance.handler_for_method_url(method_url)
|
48
|
+
if @debug == true
|
49
|
+
puts "[StripeMock req]::#{handler[:name]} #{method} #{url}"
|
50
|
+
puts " #{params}"
|
51
|
+
end
|
52
|
+
|
53
53
|
if mock_error = @error_queue.error_for_handler_name(handler[:name])
|
54
54
|
@error_queue.dequeue
|
55
55
|
raise mock_error
|
56
56
|
else
|
57
57
|
res = self.send(handler[:name], handler[:route], method_url, params, headers)
|
58
|
-
puts "[
|
58
|
+
puts " [res] #{res}" if @debug == true
|
59
59
|
[res, api_key]
|
60
60
|
end
|
61
61
|
else
|
@@ -60,18 +60,18 @@ module StripeMock
|
|
60
60
|
route =~ method_url
|
61
61
|
assert_existance :customer, $1, customers[$1]
|
62
62
|
|
63
|
-
card_id = new_id('cc') if params.delete(:card)
|
64
63
|
cus = customers[$1] ||= Data.mock_customer([], :id => $1)
|
65
64
|
cus.merge!(params)
|
66
65
|
|
67
|
-
if
|
68
|
-
new_card =
|
66
|
+
if params[:card]
|
67
|
+
new_card = get_card_by_token(params.delete(:card))
|
69
68
|
|
70
69
|
if cus[:cards][:count] == 0
|
71
70
|
cus[:cards][:count] += 1
|
72
71
|
else
|
73
72
|
cus[:cards][:data].delete_if {|card| card[:id] == cus[:default_card]}
|
74
73
|
end
|
74
|
+
|
75
75
|
cus[:cards][:data] << new_card
|
76
76
|
cus[:default_card] = new_card[:id]
|
77
77
|
end
|
data/lib/stripe_mock/version.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
shared_examples 'Card Token Mocking' do
|
4
4
|
|
5
|
-
it "generates a card token" do
|
5
|
+
it "generates and reads a card token for create customer" do
|
6
6
|
card_token = StripeMock.generate_card_token(last4: "9191", exp_month: 99, exp_year: 3005)
|
7
7
|
|
8
8
|
cus = Stripe::Customer.create(card: card_token)
|
@@ -12,4 +12,17 @@ shared_examples 'Card Token Mocking' do
|
|
12
12
|
expect(card.exp_year).to eq(3005)
|
13
13
|
end
|
14
14
|
|
15
|
+
it "generated and reads a card token for update customer" do
|
16
|
+
card_token = StripeMock.generate_card_token(last4: "1133", exp_month: 11, exp_year: 2099)
|
17
|
+
|
18
|
+
cus = Stripe::Customer.create()
|
19
|
+
cus.card = card_token
|
20
|
+
cus.save
|
21
|
+
|
22
|
+
card = cus.cards.data.first
|
23
|
+
expect(card.last4).to eq("1133")
|
24
|
+
expect(card.exp_month).to eq(11)
|
25
|
+
expect(card.exp_year).to eq(2099)
|
26
|
+
end
|
27
|
+
|
15
28
|
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.4.
|
4
|
+
version: 1.8.4.8
|
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-
|
12
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: stripe
|