stripe 1.22.0 → 1.23.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
  module Stripe
4
4
  class ListObjectTest < Test::Unit::TestCase
5
5
  should "be able to retrieve full lists given a listobject" do
6
- @mock.expects(:get).twice.returns(test_response(test_charge_array))
6
+ @mock.expects(:get).twice.returns(make_response(make_charge_array))
7
7
  c = Stripe::Charge.all
8
8
  assert c.kind_of?(Stripe::ListObject)
9
9
  assert_equal('/v1/charges', c.url)
@@ -13,4 +13,4 @@ module Stripe
13
13
  assert all.data.kind_of?(Array)
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -6,23 +6,23 @@ module Stripe
6
6
  @metadata_supported = {
7
7
  :charge => {
8
8
  :new => Stripe::Charge.method(:new),
9
- :test => method(:test_charge),
10
- :url => "/v1/charges/#{test_charge()[:id]}"
9
+ :test => method(:make_charge),
10
+ :url => "/v1/charges/#{make_charge()[:id]}"
11
11
  },
12
12
  :customer => {
13
13
  :new => Stripe::Customer.method(:new),
14
- :test => method(:test_customer),
15
- :url => "/v1/customers/#{test_customer()[:id]}"
14
+ :test => method(:make_customer),
15
+ :url => "/v1/customers/#{make_customer()[:id]}"
16
16
  },
17
17
  :recipient => {
18
18
  :new => Stripe::Recipient.method(:new),
19
- :test => method(:test_recipient),
20
- :url => "/v1/recipients/#{test_recipient()[:id]}"
19
+ :test => method(:make_recipient),
20
+ :url => "/v1/recipients/#{make_recipient()[:id]}"
21
21
  },
22
22
  :transfer => {
23
23
  :new => Stripe::Transfer.method(:new),
24
- :test => method(:test_transfer),
25
- :url => "/v1/transfers/#{test_transfer()[:id]}"
24
+ :test => method(:make_transfer),
25
+ :url => "/v1/transfers/#{make_transfer()[:id]}"
26
26
  }
27
27
  }
28
28
 
@@ -92,11 +92,11 @@ module Stripe
92
92
  url = @base_url + methods[:url]
93
93
 
94
94
  initial_test_obj = test.call(initial_params)
95
- @mock.expects(:get).once.returns(test_response(initial_test_obj))
95
+ @mock.expects(:get).once.returns(make_response(initial_test_obj))
96
96
 
97
97
  final_test_obj = test.call()
98
98
  @mock.expects(:post).once.
99
- returns(test_response(final_test_obj)).
99
+ returns(make_response(final_test_obj)).
100
100
  with(url, nil, curl_args)
101
101
 
102
102
  obj = neu.call("test")
@@ -5,13 +5,13 @@ module Stripe
5
5
  RECIPIENT_CARD_URL = '/v1/recipients/test_recipient/cards/test_card'
6
6
 
7
7
  def recipient
8
- @mock.expects(:get).once.returns(test_response(test_recipient))
8
+ @mock.expects(:get).once.returns(make_response(make_recipient))
9
9
  Stripe::Recipient.retrieve('test_recipient')
10
10
  end
11
11
 
12
12
  should "recipient cards should be listable" do
13
13
  c = recipient
14
- @mock.expects(:get).once.returns(test_response(test_recipient_card_array(recipient.id)))
14
+ @mock.expects(:get).once.returns(make_response(make_recipient_card_array(recipient.id)))
15
15
  cards = c.cards.all.data
16
16
  assert cards.kind_of? Array
17
17
  assert cards[0].kind_of? Stripe::Card
@@ -19,7 +19,7 @@ module Stripe
19
19
 
20
20
  should "recipient cards should have the correct url" do
21
21
  c = recipient
22
- @mock.expects(:get).once.returns(test_response(test_card(
22
+ @mock.expects(:get).once.returns(make_response(make_card(
23
23
  :id => 'test_card',
24
24
  :recipient => 'test_recipient'
25
25
  )))
@@ -29,8 +29,8 @@ module Stripe
29
29
 
30
30
  should "recipient cards should be deletable" do
31
31
  c = recipient
32
- @mock.expects(:get).once.returns(test_response(test_card))
33
- @mock.expects(:delete).once.returns(test_response(test_card(:deleted => true)))
32
+ @mock.expects(:get).once.returns(make_response(make_card))
33
+ @mock.expects(:delete).once.returns(make_response(make_card(:deleted => true)))
34
34
  card = c.cards.retrieve('card')
35
35
  card.delete
36
36
  assert card.deleted
@@ -38,8 +38,8 @@ module Stripe
38
38
 
39
39
  should "recipient cards should be updateable" do
40
40
  c = recipient
41
- @mock.expects(:get).once.returns(test_response(test_card(:exp_year => "2000")))
42
- @mock.expects(:post).once.returns(test_response(test_card(:exp_year => "2100")))
41
+ @mock.expects(:get).once.returns(make_response(make_card(:exp_year => "2000")))
42
+ @mock.expects(:post).once.returns(make_response(make_card(:exp_year => "2100")))
43
43
  card = c.cards.retrieve('card')
44
44
  assert_equal "2000", card.exp_year
45
45
  card.exp_year = "2100"
@@ -49,7 +49,7 @@ module Stripe
49
49
 
50
50
  should "create should return a new recipient card" do
51
51
  c = recipient
52
- @mock.expects(:post).once.returns(test_response(test_card(:id => "test_card")))
52
+ @mock.expects(:post).once.returns(make_response(make_card(:id => "test_card")))
53
53
  card = c.cards.create(:card => "tok_41YJ05ijAaWaFS")
54
54
  assert_equal "test_card", card.id
55
55
  end
@@ -3,7 +3,7 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
  module Stripe
4
4
  class RefundTest < Test::Unit::TestCase
5
5
  should "refunds should be listable" do
6
- @mock.expects(:get).once.returns(test_response(test_charge))
6
+ @mock.expects(:get).once.returns(make_response(make_charge))
7
7
 
8
8
  charge = Stripe::Charge.retrieve('test_charge')
9
9
 
@@ -11,7 +11,7 @@ module Stripe
11
11
  end
12
12
 
13
13
  should "refunds should be refreshable" do
14
- @mock.expects(:get).twice.returns(test_response(test_charge), test_response(test_refund(:id => 'refreshed_refund')))
14
+ @mock.expects(:get).twice.returns(make_response(make_charge), make_response(make_refund(:id => 'refreshed_refund')))
15
15
 
16
16
  charge = Stripe::Charge.retrieve('test_charge')
17
17
  refund = charge.refunds.first
@@ -21,8 +21,8 @@ module Stripe
21
21
  end
22
22
 
23
23
  should "refunds should be updateable" do
24
- @mock.expects(:get).once.returns(test_response(test_charge))
25
- @mock.expects(:post).once.returns(test_response(test_refund(:metadata => {'key' => 'value'})))
24
+ @mock.expects(:get).once.returns(make_response(make_charge))
25
+ @mock.expects(:post).once.returns(make_response(make_refund(:metadata => {'key' => 'value'})))
26
26
 
27
27
  charge = Stripe::Charge.retrieve('test_charge')
28
28
  refund = charge.refunds.first
@@ -36,8 +36,8 @@ module Stripe
36
36
  end
37
37
 
38
38
  should "create should return a new refund" do
39
- @mock.expects(:get).once.returns(test_response(test_charge))
40
- @mock.expects(:post).once.returns(test_response(test_refund(:id => 'test_new_refund')))
39
+ @mock.expects(:get).once.returns(make_response(make_charge))
40
+ @mock.expects(:post).once.returns(make_response(make_refund(:id => 'test_new_refund')))
41
41
 
42
42
  charge = Stripe::Charge.retrieve('test_charge')
43
43
  refund = charge.refunds.create(:amount => 20)
@@ -3,7 +3,7 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
  module Stripe
4
4
  class ReversalTest < Test::Unit::TestCase
5
5
  should "reversals should be listable" do
6
- @mock.expects(:get).once.returns(test_response(test_transfer))
6
+ @mock.expects(:get).once.returns(make_response(make_transfer))
7
7
 
8
8
  transfer = Stripe::Transfer.retrieve('test_transfer')
9
9
 
@@ -11,7 +11,7 @@ module Stripe
11
11
  end
12
12
 
13
13
  should "reversals should be refreshable" do
14
- @mock.expects(:get).twice.returns(test_response(test_transfer), test_response(test_reversal(:id => 'refreshed_reversal')))
14
+ @mock.expects(:get).twice.returns(make_response(make_transfer), make_response(make_reversal(:id => 'refreshed_reversal')))
15
15
 
16
16
  transfer = Stripe::Transfer.retrieve('test_transfer')
17
17
  reversal = transfer.reversals.first
@@ -21,8 +21,8 @@ module Stripe
21
21
  end
22
22
 
23
23
  should "reversals should be updateable" do
24
- @mock.expects(:get).once.returns(test_response(test_transfer))
25
- @mock.expects(:post).once.returns(test_response(test_reversal(:metadata => {'key' => 'value'})))
24
+ @mock.expects(:get).once.returns(make_response(make_transfer))
25
+ @mock.expects(:post).once.returns(make_response(make_reversal(:metadata => {'key' => 'value'})))
26
26
 
27
27
  transfer = Stripe::Transfer.retrieve('test_transfer')
28
28
  reversal = transfer.reversals.first
@@ -36,8 +36,8 @@ module Stripe
36
36
  end
37
37
 
38
38
  should "create should return a new reversal" do
39
- @mock.expects(:get).once.returns(test_response(test_transfer))
40
- @mock.expects(:post).once.returns(test_response(test_reversal(:id => 'test_new_reversal')))
39
+ @mock.expects(:get).once.returns(make_response(make_transfer))
40
+ @mock.expects(:post).once.returns(make_response(make_reversal(:id => 'test_new_reversal')))
41
41
 
42
42
  transfer = Stripe::Transfer.retrieve('test_transfer')
43
43
  reversals = transfer.reversals.create(:amount => 20)
@@ -3,7 +3,7 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
  module Stripe
4
4
  class SubscriptionTest < Test::Unit::TestCase
5
5
  should "subscriptions should be listable" do
6
- @mock.expects(:get).once.returns(test_response(test_customer))
6
+ @mock.expects(:get).once.returns(make_response(make_customer))
7
7
 
8
8
  customer = Stripe::Customer.retrieve('test_customer')
9
9
 
@@ -11,7 +11,7 @@ module Stripe
11
11
  end
12
12
 
13
13
  should "subscriptions should be refreshable" do
14
- @mock.expects(:get).twice.returns(test_response(test_customer), test_response(test_subscription(:id => 'refreshed_subscription')))
14
+ @mock.expects(:get).twice.returns(make_response(make_customer), make_response(make_subscription(:id => 'refreshed_subscription')))
15
15
 
16
16
  customer = Stripe::Customer.retrieve('test_customer')
17
17
  subscription = customer.subscriptions.first
@@ -21,20 +21,20 @@ module Stripe
21
21
  end
22
22
 
23
23
  should "subscriptions should be deletable" do
24
- @mock.expects(:get).once.returns(test_response(test_customer))
24
+ @mock.expects(:get).once.returns(make_response(make_customer))
25
25
  customer = Stripe::Customer.retrieve('test_customer')
26
26
  subscription = customer.subscriptions.first
27
27
 
28
- @mock.expects(:delete).once.with("#{Stripe.api_base}/v1/customers/c_test_customer/subscriptions/#{subscription.id}?at_period_end=true", nil, nil).returns(test_response(test_subscription))
28
+ @mock.expects(:delete).once.with("#{Stripe.api_base}/v1/customers/c_test_customer/subscriptions/#{subscription.id}?at_period_end=true", nil, nil).returns(make_response(make_subscription))
29
29
  subscription.delete :at_period_end => true
30
30
 
31
- @mock.expects(:delete).once.with("#{Stripe.api_base}/v1/customers/c_test_customer/subscriptions/#{subscription.id}", nil, nil).returns(test_response(test_subscription))
31
+ @mock.expects(:delete).once.with("#{Stripe.api_base}/v1/customers/c_test_customer/subscriptions/#{subscription.id}", nil, nil).returns(make_response(make_subscription))
32
32
  subscription.delete
33
33
  end
34
34
 
35
35
  should "subscriptions should be updateable" do
36
- @mock.expects(:get).once.returns(test_response(test_customer))
37
- @mock.expects(:post).once.returns(test_response(test_subscription({:status => 'active'})))
36
+ @mock.expects(:get).once.returns(make_response(make_customer))
37
+ @mock.expects(:post).once.returns(make_response(make_subscription({:status => 'active'})))
38
38
 
39
39
  customer = Stripe::Customer.retrieve('test_customer')
40
40
  subscription = customer.subscriptions.first
@@ -47,8 +47,8 @@ module Stripe
47
47
  end
48
48
 
49
49
  should "create should return a new subscription" do
50
- @mock.expects(:get).once.returns(test_response(test_customer))
51
- @mock.expects(:post).once.returns(test_response(test_subscription(:id => 'test_new_subscription')))
50
+ @mock.expects(:get).once.returns(make_response(make_customer))
51
+ @mock.expects(:post).once.returns(make_response(make_subscription(:id => 'test_new_subscription')))
52
52
 
53
53
  customer = Stripe::Customer.retrieve('test_customer')
54
54
  subscription = customer.subscriptions.create(:plan => 'silver')
@@ -56,15 +56,15 @@ module Stripe
56
56
  end
57
57
 
58
58
  should "be able to delete a subscriptions's discount" do
59
- @mock.expects(:get).once.returns(test_response(test_customer))
60
- @mock.expects(:post).once.returns(test_response(test_subscription(:id => 'test_new_subscription')))
59
+ @mock.expects(:get).once.returns(make_response(make_customer))
60
+ @mock.expects(:post).once.returns(make_response(make_subscription(:id => 'test_new_subscription')))
61
61
 
62
62
 
63
- customer = Stripe::Customer.retrieve("test_customer")
63
+ customer = Stripe::Customer.retrieve('test_customer')
64
64
  subscription = customer.subscriptions.create(:plan => 'silver')
65
65
 
66
66
  url = "#{Stripe.api_base}/v1/customers/c_test_customer/subscriptions/test_new_subscription/discount"
67
- @mock.expects(:delete).once.with(url, nil, nil).returns(test_response(test_delete_discount_response))
67
+ @mock.expects(:delete).once.with(url, nil, nil).returns(make_response(make_delete_discount_response))
68
68
  subscription.delete_discount
69
69
  assert_equal nil, subscription.discount
70
70
  end
@@ -3,22 +3,22 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
  module Stripe
4
4
  class TransferTest < Test::Unit::TestCase
5
5
  should "retrieve should retrieve transfer" do
6
- @mock.expects(:get).once.returns(test_response(test_transfer))
6
+ @mock.expects(:get).once.returns(make_response(make_transfer))
7
7
  transfer = Stripe::Transfer.retrieve('tr_test_transfer')
8
8
  assert_equal 'tr_test_transfer', transfer.id
9
9
  end
10
10
 
11
11
  should "create should create a transfer" do
12
- @mock.expects(:post).once.returns(test_response(test_transfer))
12
+ @mock.expects(:post).once.returns(make_response(make_transfer))
13
13
  transfer = Stripe::Transfer.create
14
14
  assert_equal "tr_test_transfer", transfer.id
15
15
  end
16
16
 
17
17
  should "cancel should cancel a transfer" do
18
- @mock.expects(:get).once.returns(test_response(test_transfer))
18
+ @mock.expects(:get).once.returns(make_response(make_transfer))
19
19
  transfer = Stripe::Transfer.retrieve('tr_test_transfer')
20
20
 
21
- @mock.expects(:post).once.with('https://api.stripe.com/v1/transfers/tr_test_transfer/cancel', nil, '').returns(test_response(test_canceled_transfer))
21
+ @mock.expects(:post).once.with('https://api.stripe.com/v1/transfers/tr_test_transfer/cancel', nil, '').returns(make_response(make_canceled_transfer))
22
22
  transfer.cancel
23
23
  end
24
24
  end
data/test/test_data.rb CHANGED
@@ -1,17 +1,22 @@
1
1
  module Stripe
2
2
  module TestData
3
- def test_response(body, code=200)
3
+ def make_response(body, code=200)
4
4
  # When an exception is raised, restclient clobbers method_missing. Hence we
5
5
  # can't just use the stubs interface.
6
6
  body = JSON.generate(body) if !(body.kind_of? String)
7
7
  m = mock
8
- m.instance_variable_set('@stripe_values', { :body => body, :code => code })
8
+ m.instance_variable_set('@stripe_values', {
9
+ :body => body,
10
+ :code => code,
11
+ :headers => {},
12
+ })
9
13
  def m.body; @stripe_values[:body]; end
10
14
  def m.code; @stripe_values[:code]; end
15
+ def m.headers; @stripe_values[:headers]; end
11
16
  m
12
17
  end
13
18
 
14
- def test_balance(params={})
19
+ def make_balance(params={})
15
20
  {
16
21
  :pending => [
17
22
  {:amount => 12345, :currency => "usd"}
@@ -24,7 +29,7 @@ module Stripe
24
29
  }.merge(params)
25
30
  end
26
31
 
27
- def test_balance_transaction(params={})
32
+ def make_balance_transaction(params={})
28
33
  {
29
34
  :amount => 100,
30
35
  :net => 41,
@@ -39,15 +44,15 @@ module Stripe
39
44
  }.merge(params)
40
45
  end
41
46
 
42
- def test_balance_transaction_array
47
+ def make_balance_transaction_array
43
48
  {
44
- :data => [test_balance_transaction, test_balance_transaction, test_balance_transaction],
49
+ :data => [make_balance_transaction, make_balance_transaction, make_balance_transaction],
45
50
  :object => "list",
46
51
  :url => "/v1/balance/history"
47
52
  }
48
53
  end
49
54
 
50
- def test_application_fee(params={})
55
+ def make_application_fee(params={})
51
56
  id = params[:id] || 'fee_test_fee'
52
57
  {
53
58
  :refunded => false,
@@ -59,12 +64,12 @@ module Stripe
59
64
  :livemode => false,
60
65
  :currency => "usd",
61
66
  :object => "application_fee",
62
- :refunds => test_application_fee_refund_array(id),
67
+ :refunds => make_application_fee_refund_array(id),
63
68
  :created => 1304114826
64
69
  }.merge(params)
65
70
  end
66
71
 
67
- def test_application_fee_refund(params = {})
72
+ def make_application_fee_refund(params = {})
68
73
  {
69
74
  :object => 'fee_refund',
70
75
  :amount => 30,
@@ -76,23 +81,23 @@ module Stripe
76
81
  }.merge(params)
77
82
  end
78
83
 
79
- def test_application_fee_array
84
+ def make_application_fee_array
80
85
  {
81
- :data => [test_application_fee, test_application_fee, test_application_fee],
86
+ :data => [make_application_fee, make_application_fee, make_application_fee],
82
87
  :object => 'list',
83
88
  :url => '/v1/application_fees'
84
89
  }
85
90
  end
86
91
 
87
- def test_application_fee_refund_array(fee_id)
92
+ def make_application_fee_refund_array(fee_id)
88
93
  {
89
- :data => [test_application_fee_refund, test_application_fee_refund, test_application_fee_refund],
94
+ :data => [make_application_fee_refund, make_application_fee_refund, make_application_fee_refund],
90
95
  :object => 'list',
91
96
  :url => '/v1/application_fees/' + fee_id + '/refunds'
92
97
  }
93
98
  end
94
99
 
95
- def test_customer(params={})
100
+ def make_customer(params={})
96
101
  id = params[:id] || 'c_test_customer'
97
102
  {
98
103
  :subscription_history => [],
@@ -103,21 +108,21 @@ module Stripe
103
108
  :id => id,
104
109
  :default_card => "cc_test_card",
105
110
  :created => 1304114758,
106
- :sources => test_customer_card_array(id),
111
+ :sources => make_customer_card_array(id),
107
112
  :metadata => {},
108
- :subscriptions => test_subscription_array(id)
113
+ :subscriptions => make_subscription_array(id)
109
114
  }.merge(params)
110
115
  end
111
116
 
112
- def test_customer_array
117
+ def make_customer_array
113
118
  {
114
- :data => [test_customer, test_customer, test_customer],
119
+ :data => [make_customer, make_customer, make_customer],
115
120
  :object => 'list',
116
121
  :url => '/v1/customers'
117
122
  }
118
123
  end
119
124
 
120
- def test_charge(params={})
125
+ def make_charge(params={})
121
126
  id = params[:id] || 'ch_test_charge'
122
127
  {
123
128
  :refunded => false,
@@ -138,36 +143,36 @@ module Stripe
138
143
  :currency => "usd",
139
144
  :object => "charge",
140
145
  :created => 1304114826,
141
- :refunds => test_refund_array(id),
146
+ :refunds => make_refund_array(id),
142
147
  :metadata => {}
143
148
  }.merge(params)
144
149
  end
145
150
 
146
- def test_charge_array
151
+ def make_charge_array
147
152
  {
148
- :data => [test_charge, test_charge, test_charge],
153
+ :data => [make_charge, make_charge, make_charge],
149
154
  :object => 'list',
150
155
  :url => '/v1/charges'
151
156
  }
152
157
  end
153
158
 
154
- def test_recipient_card_array(recipient_id)
159
+ def make_recipient_card_array(recipient_id)
155
160
  {
156
- :data => [test_card, test_card, test_card],
161
+ :data => [make_card, make_card, make_card],
157
162
  :object => 'list',
158
163
  :url => '/v1/recipients/' + recipient_id + '/cards'
159
164
  }
160
165
  end
161
166
 
162
- def test_customer_card_array(customer_id)
167
+ def make_customer_card_array(customer_id)
163
168
  {
164
- :data => [test_card, test_card, test_card],
169
+ :data => [make_card, make_card, make_card],
165
170
  :object => 'list',
166
171
  :url => '/v1/customers/' + customer_id + '/sources'
167
172
  }
168
173
  end
169
174
 
170
- def test_card(params={})
175
+ def make_card(params={})
171
176
  {
172
177
  :type => "Visa",
173
178
  :last4 => "4242",
@@ -180,7 +185,7 @@ module Stripe
180
185
  }.merge(params)
181
186
  end
182
187
 
183
- def test_coupon(params={})
188
+ def make_coupon(params={})
184
189
  {
185
190
  :duration => 'repeating',
186
191
  :duration_in_months => 3,
@@ -191,7 +196,7 @@ module Stripe
191
196
  }.merge(params)
192
197
  end
193
198
 
194
- def test_file(params={})
199
+ def make_file(params={})
195
200
  {
196
201
  :object => "file_upload",
197
202
  :id => "fil_test_file",
@@ -203,16 +208,16 @@ module Stripe
203
208
  }
204
209
  end
205
210
 
206
- def test_file_array
211
+ def make_file_array
207
212
  {
208
- :data => [test_file, test_file, test_file],
213
+ :data => [make_file, make_file, make_file],
209
214
  :object => 'list',
210
215
  :url => '/v1/files'
211
216
  }
212
217
  end
213
218
 
214
219
  #FIXME nested overrides would be better than hardcoding plan_id
215
- def test_subscription(params = {})
220
+ def make_subscription(params = {})
216
221
  plan = params.delete(:plan) || 'gold'
217
222
  {
218
223
  :current_period_end => 1308681468,
@@ -234,7 +239,7 @@ module Stripe
234
239
  }.merge(params)
235
240
  end
236
241
 
237
- def test_refund(params = {})
242
+ def make_refund(params = {})
238
243
  {
239
244
  :object => 'refund',
240
245
  :amount => 30,
@@ -246,31 +251,31 @@ module Stripe
246
251
  }.merge(params)
247
252
  end
248
253
 
249
- def test_subscription_array(customer_id)
254
+ def make_subscription_array(customer_id)
250
255
  {
251
- :data => [test_subscription, test_subscription, test_subscription],
256
+ :data => [make_subscription, make_subscription, make_subscription],
252
257
  :object => 'list',
253
258
  :url => '/v1/customers/' + customer_id + '/subscriptions'
254
259
  }
255
260
  end
256
261
 
257
- def test_refund_array(charge_id)
262
+ def make_refund_array(charge_id)
258
263
  {
259
- :data => [test_refund, test_refund, test_refund],
264
+ :data => [make_refund, make_refund, make_refund],
260
265
  :object => 'list',
261
266
  :url => '/v1/charges/' + charge_id + '/refunds'
262
267
  }
263
268
  end
264
269
 
265
- def test_reversal_array(transfer_id)
270
+ def make_reversal_array(transfer_id)
266
271
  {
267
- :data => [test_reversal, test_reversal, test_reversal],
272
+ :data => [make_reversal, make_reversal, make_reversal],
268
273
  :object => 'list',
269
274
  :url => '/v1/transfers/' + transfer_id + '/reversals'
270
275
  }
271
276
  end
272
277
 
273
- def test_invoice
278
+ def make_invoice
274
279
  {
275
280
  :id => 'in_test_invoice',
276
281
  :object => 'invoice',
@@ -310,8 +315,8 @@ module Stripe
310
315
  }
311
316
  end
312
317
 
313
- def test_paid_invoice
314
- test_invoice.merge({
318
+ def make_paid_invoice
319
+ make_invoice.merge({
315
320
  :attempt_count => 1,
316
321
  :attempted => true,
317
322
  :closed => true,
@@ -322,15 +327,15 @@ module Stripe
322
327
  })
323
328
  end
324
329
 
325
- def test_invoice_customer_array
330
+ def make_invoice_customer_array
326
331
  {
327
- :data => [test_invoice],
332
+ :data => [make_invoice],
328
333
  :object => 'list',
329
334
  :url => '/v1/invoices?customer=test_customer'
330
335
  }
331
336
  end
332
337
 
333
- def test_recipient(params={})
338
+ def make_recipient(params={})
334
339
  id = params[:id] || 'rp_test_recipient'
335
340
  {
336
341
  :name => "Stripe User",
@@ -338,7 +343,7 @@ module Stripe
338
343
  :livemode => false,
339
344
  :object => "recipient",
340
345
  :id => "rp_test_recipient",
341
- :cards => test_recipient_card_array(id),
346
+ :cards => make_recipient_card_array(id),
342
347
  :default_card => "debit_test_card",
343
348
  :active_account => {
344
349
  :last4 => "6789",
@@ -352,15 +357,15 @@ module Stripe
352
357
  }.merge(params)
353
358
  end
354
359
 
355
- def test_recipient_array
360
+ def make_recipient_array
356
361
  {
357
- :data => [test_recipient, test_recipient, test_recipient],
362
+ :data => [make_recipient, make_recipient, make_recipient],
358
363
  :object => 'list',
359
364
  :url => '/v1/recipients'
360
365
  }
361
366
  end
362
367
 
363
- def test_transfer(params={})
368
+ def make_transfer(params={})
364
369
  {
365
370
  :status => 'pending',
366
371
  :amount => 100,
@@ -374,7 +379,7 @@ module Stripe
374
379
  :fee => 0,
375
380
  :fee_details => [],
376
381
  :id => "tr_test_transfer",
377
- :reversals => test_reversal_array('tr_test_transfer'),
382
+ :reversals => make_reversal_array('tr_test_transfer'),
378
383
  :livemode => false,
379
384
  :currency => "usd",
380
385
  :object => "transfer",
@@ -383,21 +388,21 @@ module Stripe
383
388
  }.merge(params)
384
389
  end
385
390
 
386
- def test_transfer_array
391
+ def make_transfer_array
387
392
  {
388
- :data => [test_transfer, test_transfer, test_transfer],
393
+ :data => [make_transfer, make_transfer, make_transfer],
389
394
  :object => 'list',
390
395
  :url => '/v1/transfers'
391
396
  }
392
397
  end
393
398
 
394
- def test_canceled_transfer
395
- test_transfer.merge({
399
+ def make_canceled_transfer
400
+ make_transfer.merge({
396
401
  :status => 'canceled'
397
402
  })
398
403
  end
399
404
 
400
- def test_reversal(params={})
405
+ def make_reversal(params={})
401
406
  {
402
407
  :object => 'transfer_reversal',
403
408
  :amount => 30,
@@ -409,7 +414,7 @@ module Stripe
409
414
  }.merge(params)
410
415
  end
411
416
 
412
- def test_bitcoin_receiver(params={})
417
+ def make_bitcoin_receiver(params={})
413
418
  {
414
419
  :id => 'btcrcv_test_receiver',
415
420
  :amount => 100,
@@ -417,19 +422,19 @@ module Stripe
417
422
  :description => 'some details',
418
423
  :metadata => {},
419
424
  :object => 'bitcoin_receiver',
420
- :transactions => test_bitcoin_transaction_array
425
+ :transactions => make_bitcoin_transaction_array
421
426
  }.merge(params)
422
427
  end
423
428
 
424
- def test_bitcoin_receiver_array
429
+ def make_bitcoin_receiver_array
425
430
  {
426
- :data => [test_bitcoin_receiver, test_bitcoin_receiver, test_bitcoin_receiver],
431
+ :data => [make_bitcoin_receiver, make_bitcoin_receiver, make_bitcoin_receiver],
427
432
  :object => 'list',
428
433
  :url => '/v1/bitcoin/receivers'
429
434
  }
430
435
  end
431
436
 
432
- def test_bitcoin_transaction(params={})
437
+ def make_bitcoin_transaction(params={})
433
438
  {
434
439
  :id => 'btctxn_test_transaction',
435
440
  :object => 'bitcoin_transaction',
@@ -440,15 +445,15 @@ module Stripe
440
445
  }.merge(params)
441
446
  end
442
447
 
443
- def test_bitcoin_transaction_array
448
+ def make_bitcoin_transaction_array
444
449
  {
445
- :data => [test_bitcoin_transaction, test_bitcoin_transaction, test_bitcoin_transaction],
450
+ :data => [make_bitcoin_transaction, make_bitcoin_transaction, make_bitcoin_transaction],
446
451
  :object => 'list',
447
452
  :url => "/v1/bitcoin/receivers/btcrcv_test_receiver/transactions"
448
453
  }
449
454
  end
450
455
 
451
- def test_invalid_api_key_error
456
+ def make_invalid_api_key_error
452
457
  {
453
458
  :error => {
454
459
  :type => "invalid_request_error",
@@ -457,7 +462,7 @@ module Stripe
457
462
  }
458
463
  end
459
464
 
460
- def test_invalid_exp_year_error
465
+ def make_invalid_exp_year_error
461
466
  {
462
467
  :error => {
463
468
  :code => "invalid_expiry_year",
@@ -468,7 +473,7 @@ module Stripe
468
473
  }
469
474
  end
470
475
 
471
- def test_missing_id_error
476
+ def make_missing_id_error
472
477
  {
473
478
  :error => {
474
479
  :param => "id",
@@ -478,7 +483,7 @@ module Stripe
478
483
  }
479
484
  end
480
485
 
481
- def test_api_error
486
+ def make_api_error
482
487
  {
483
488
  :error => {
484
489
  :type => "api_error"
@@ -486,7 +491,7 @@ module Stripe
486
491
  }
487
492
  end
488
493
 
489
- def test_delete_discount_response
494
+ def make_delete_discount_response
490
495
  {
491
496
  :deleted => true,
492
497
  :id => "di_test_coupon"