stripe-ruby-mock 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  In your gemfile:
10
10
 
11
- gem 'stripe-ruby-mock', '~> 2.0.2', :require => 'stripe_mock'
11
+ gem 'stripe-ruby-mock', '~> 2.0.3', :require => 'stripe_mock'
12
12
 
13
13
  ## Features
14
14
 
@@ -1,6 +1,6 @@
1
1
  module StripeMock
2
2
 
3
- def self.mock_webhook_event(type, params={})
3
+ def self.mock_webhook_payload(type, params = {})
4
4
 
5
5
  fixture_file = File.join(@webhook_fixture_path, "#{type}.json")
6
6
 
@@ -25,8 +25,11 @@ module StripeMock
25
25
  else
26
26
  raise UnstartedStateError
27
27
  end
28
+ event_data
29
+ end
28
30
 
29
- Stripe::Event.construct_from(event_data)
31
+ def self.mock_webhook_event(type, params={})
32
+ Stripe::Event.construct_from(mock_webhook_payload(type, params))
30
33
  end
31
34
 
32
35
  module Webhooks
@@ -8,6 +8,7 @@ module StripeMock
8
8
  klass.add_handler 'get /v1/customers/(.*)/cards/(.*)', :retrieve_card
9
9
  klass.add_handler 'delete /v1/customers/(.*)/cards/(.*)', :delete_card
10
10
  klass.add_handler 'post /v1/customers/(.*)/cards/(.*)', :update_card
11
+ klass.add_handler 'get /v1/recipients/(.*)/cards', :retrieve_recipient_cards
11
12
  klass.add_handler 'get /v1/recipients/(.*)/cards/(.*)', :retrieve_recipient_card
12
13
  klass.add_handler 'post /v1/recipients/(.*)/cards', :create_recipient_card
13
14
  klass.add_handler 'delete /v1/recipients/(.*)/cards/(.*)', :delete_recipient_card
@@ -25,10 +26,12 @@ module StripeMock
25
26
 
26
27
  def retrieve_cards(route, method_url, params, headers)
27
28
  route =~ method_url
28
- customer = assert_existence :customer, $1, customers[$1]
29
- cards = customer[:cards]
29
+ retrieve_object_cards(:customer, $1, customers)
30
+ end
30
31
 
31
- Data.mock_list_object(cards[:data])
32
+ def retrieve_recipient_cards(route, method_url, params, headers)
33
+ route =~ method_url
34
+ retrieve_object_cards(:recipient, $1, recipients)
32
35
  end
33
36
 
34
37
  def retrieve_card(route, method_url, params, headers)
@@ -27,6 +27,13 @@ module StripeMock
27
27
  card
28
28
  end
29
29
 
30
+ def retrieve_object_cards(type, type_id, objects)
31
+ resource = assert_existence type, type_id, objects[type_id]
32
+ cards = resource[:cards]
33
+
34
+ Data.mock_list_object(cards[:data])
35
+ end
36
+
30
37
  def delete_card_from(type, type_id, card_id, objects)
31
38
  resource = assert_existence type, type_id, objects[type_id]
32
39
 
@@ -1,4 +1,4 @@
1
1
  module StripeMock
2
2
  # stripe-ruby-mock version
3
- VERSION = "2.0.2"
3
+ VERSION = "2.0.3"
4
4
  end
@@ -122,6 +122,11 @@ shared_examples 'Card API' do
122
122
  let!(:card_token) { stripe_helper.generate_card_token(last4: "1123", exp_month: 11, exp_year: 2099) }
123
123
  let!(:card) { customer.cards.create(card: card_token) }
124
124
 
125
+ it "can retrieve all customer's cards" do
126
+ retrieved = customer.cards.all
127
+ expect(retrieved.count).to eq(1)
128
+ end
129
+
125
130
  it "retrieves a customers card" do
126
131
  retrieved = customer.cards.retrieve(card.id)
127
132
  expect(retrieved.to_s).to eq(card.to_s)
@@ -174,6 +179,11 @@ shared_examples 'Card API' do
174
179
  let!(:card_token) { stripe_helper.generate_card_token(number: "4000056655665556") }
175
180
  let!(:card) { recipient.cards.create(card: card_token) }
176
181
 
182
+ it "can retrieve all recipient's cards" do
183
+ retrieved = recipient.cards.all
184
+ expect(retrieved.count).to eq(1)
185
+ end
186
+
177
187
  it "deletes a recipient card" do
178
188
  card.delete
179
189
  retrieved_cus = Stripe::Recipient.retrieve(recipient.id)
@@ -14,14 +14,20 @@ shared_examples 'Webhook Events API' do
14
14
 
15
15
  it "first looks in spec/fixtures/stripe_webhooks/ for fixtures by default" do
16
16
  event = StripeMock.mock_webhook_event('account.updated')
17
+ payload = StripeMock.mock_webhook_payload('account.updated')
17
18
  expect(event).to be_a(Stripe::Event)
18
19
  expect(event.id).to match /^test_evt_[0-9]+/
19
20
  expect(event.type).to eq('account.updated')
21
+
22
+ expect(payload).to be_a(Hash)
23
+ expect(payload[:id]).to match /^test_evt_[0-9]+/
24
+ expect(payload[:type]).to eq('account.updated')
20
25
  end
21
26
 
22
27
  it "allows non-standard event names in the project fixture folder" do
23
28
  expect {
24
29
  event = StripeMock.mock_webhook_event('custom.account.updated')
30
+ StripeMock.mock_webhook_payload('custom.account.updated')
25
31
  }.to_not raise_error
26
32
  end
27
33
 
@@ -32,7 +38,9 @@ shared_examples 'Webhook Events API' do
32
38
  expect(StripeMock.webhook_fixture_path).to eq('./spec/_dummy/webhooks/')
33
39
 
34
40
  event = StripeMock.mock_webhook_event('dummy.event')
41
+ payload = StripeMock.mock_webhook_payload('dummy.event')
35
42
  expect(event.val).to eq('success')
43
+ expect(payload[:val]).to eq('success')
36
44
 
37
45
  StripeMock.webhook_fixture_path = original_path
38
46
  end
@@ -75,7 +83,11 @@ shared_examples 'Webhook Events API' do
75
83
  event = StripeMock.mock_webhook_event('customer.created', {
76
84
  :account_balance => 12345
77
85
  })
86
+ payload = StripeMock.mock_webhook_event('customer.created', {
87
+ :account_balance => 12345
88
+ })
78
89
  expect(event.data.object.account_balance).to eq(12345)
90
+ expect(payload[:data][:object][:account_balance]).to eq(12345)
79
91
  end
80
92
 
81
93
  it "takes a hash and deep merges arrays in the data object" do
@@ -105,6 +117,10 @@ shared_examples 'Webhook Events API' do
105
117
  expect {
106
118
  event = StripeMock.mock_webhook_event('cow.bell')
107
119
  }.to raise_error StripeMock::UnsupportedRequestError
120
+
121
+ expect {
122
+ StripeMock.mock_webhook_payload('cow.bell')
123
+ }.to raise_error StripeMock::UnsupportedRequestError
108
124
  end
109
125
 
110
126
  end
metadata CHANGED
@@ -1,60 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-ruby-mock
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Gilbert
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-02-10 00:00:00.000000000 Z
12
+ date: 2015-02-12 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: stripe
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 1.15.0
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: 1.15.0
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: jimson-temp
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: dante
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: 0.2.0
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: 0.2.0
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rspec
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: rubygems-tasks
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ~>
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ~>
81
92
  - !ruby/object:Gem::Version
@@ -83,15 +94,17 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: thin
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
- - - '>='
99
+ - - ! '>='
88
100
  - !ruby/object:Gem::Version
89
101
  version: '0'
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
- - - '>='
107
+ - - ! '>='
95
108
  - !ruby/object:Gem::Version
96
109
  version: '0'
97
110
  description: A drop-in library to test stripe without hitting their servers
@@ -229,26 +242,27 @@ files:
229
242
  homepage: https://github.com/rebelidealist/stripe-ruby-mock
230
243
  licenses:
231
244
  - MIT
232
- metadata: {}
233
245
  post_install_message:
234
246
  rdoc_options: []
235
247
  require_paths:
236
248
  - lib
237
249
  required_ruby_version: !ruby/object:Gem::Requirement
250
+ none: false
238
251
  requirements:
239
- - - '>='
252
+ - - ! '>='
240
253
  - !ruby/object:Gem::Version
241
254
  version: '0'
242
255
  required_rubygems_version: !ruby/object:Gem::Requirement
256
+ none: false
243
257
  requirements:
244
- - - '>='
258
+ - - ! '>='
245
259
  - !ruby/object:Gem::Version
246
260
  version: '0'
247
261
  requirements: []
248
262
  rubyforge_project:
249
- rubygems_version: 2.2.2
263
+ rubygems_version: 1.8.25
250
264
  signing_key:
251
- specification_version: 4
265
+ specification_version: 3
252
266
  summary: TDD with stripe
253
267
  test_files:
254
268
  - spec/_dummy/webhooks/dummy.event.json
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: b72e2ccbae6fb810bf3d2a73fc6ddeb072badc6b
4
- data.tar.gz: 1022933805ff7d31061036afb39884abcbd5a048
5
- SHA512:
6
- metadata.gz: 88d880ba38c32c1df49c39921a05770b1545232469ae771e9979a3b8a0ad65cfa7db8e7ad22dbcdbe376b5ebcaa035d45f5eac623531d0269a1492cf38778537
7
- data.tar.gz: 5c96162f36106a8869c093def7b0de6f020f57b17b10a514e1994bc324565a3c12d43a0b59ecd73392985b6878ffca67831a76ee7abac5d3f8ccba3e5b3fb18a