braintree 2.4.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/README.rdoc +4 -0
  2. data/lib/braintree.rb +43 -32
  3. data/lib/braintree/add_on.rb +4 -0
  4. data/lib/braintree/address.rb +18 -72
  5. data/lib/braintree/address_gateway.rb +76 -0
  6. data/lib/braintree/advanced_search.rb +31 -13
  7. data/lib/braintree/base_module.rb +6 -0
  8. data/lib/braintree/configuration.rb +57 -39
  9. data/lib/braintree/credit_card.rb +75 -129
  10. data/lib/braintree/credit_card_gateway.rb +133 -0
  11. data/lib/braintree/credit_card_verification.rb +8 -0
  12. data/lib/braintree/customer.rb +70 -123
  13. data/lib/braintree/customer_gateway.rb +121 -0
  14. data/lib/braintree/digest.rb +2 -2
  15. data/lib/braintree/discount.rb +4 -0
  16. data/lib/braintree/error_codes.rb +50 -5
  17. data/lib/braintree/error_result.rb +4 -18
  18. data/lib/braintree/errors.rb +1 -2
  19. data/lib/braintree/exceptions.rb +11 -16
  20. data/lib/braintree/gateway.rb +39 -0
  21. data/lib/braintree/http.rb +30 -26
  22. data/lib/braintree/modification.rb +23 -0
  23. data/lib/braintree/resource_collection.rb +1 -1
  24. data/lib/braintree/subscription.rb +29 -129
  25. data/lib/braintree/subscription_gateway.rb +122 -0
  26. data/lib/braintree/subscription_search.rb +6 -7
  27. data/lib/braintree/successful_result.rb +1 -12
  28. data/lib/braintree/test/credit_card_numbers.rb +4 -2
  29. data/lib/braintree/test/transaction_amounts.rb +3 -0
  30. data/lib/braintree/transaction.rb +83 -243
  31. data/lib/braintree/transaction/credit_card_details.rb +4 -4
  32. data/lib/braintree/transaction_gateway.rb +124 -0
  33. data/lib/braintree/transaction_search.rb +5 -3
  34. data/lib/braintree/transparent_redirect.rb +19 -112
  35. data/lib/braintree/transparent_redirect_gateway.rb +105 -0
  36. data/lib/braintree/util.rb +4 -0
  37. data/lib/braintree/validation_error.rb +1 -0
  38. data/lib/braintree/validation_error_collection.rb +5 -23
  39. data/lib/braintree/version.rb +2 -2
  40. data/lib/braintree/xml/parser.rb +1 -1
  41. data/lib/braintree/xml/rexml.rb +2 -2
  42. data/spec/integration/braintree/advanced_search_spec.rb +532 -0
  43. data/spec/integration/braintree/credit_card_spec.rb +5 -8
  44. data/spec/integration/braintree/http_spec.rb +53 -39
  45. data/spec/integration/braintree/subscription_spec.rb +678 -213
  46. data/spec/integration/braintree/transaction_search_spec.rb +318 -43
  47. data/spec/integration/braintree/transaction_spec.rb +134 -3
  48. data/spec/integration/braintree/transparent_redirect_spec.rb +1 -1
  49. data/spec/spec_helper.rb +55 -4
  50. data/spec/unit/braintree/address_spec.rb +8 -8
  51. data/spec/unit/braintree/base_module_spec.rb +1 -1
  52. data/spec/unit/braintree/configuration_spec.rb +34 -29
  53. data/spec/unit/braintree/credit_card_spec.rb +14 -12
  54. data/spec/unit/braintree/credit_card_verification_spec.rb +16 -0
  55. data/spec/unit/braintree/customer_spec.rb +10 -8
  56. data/spec/unit/braintree/digest_spec.rb +8 -17
  57. data/spec/unit/braintree/error_result_spec.rb +12 -2
  58. data/spec/unit/braintree/http_spec.rb +2 -2
  59. data/spec/unit/braintree/subscription_search_spec.rb +77 -0
  60. data/spec/unit/braintree/subscription_spec.rb +16 -8
  61. data/spec/unit/braintree/transaction_spec.rb +17 -12
  62. data/spec/unit/braintree/transparent_redirect_spec.rb +12 -12
  63. data/spec/unit/braintree/util_spec.rb +24 -0
  64. data/spec/unit/braintree/xml/parser_spec.rb +1 -1
  65. data/spec/unit/braintree_spec.rb +1 -1
  66. metadata +16 -5
@@ -1,4 +1,5 @@
1
1
  module Braintree
2
+ # See http://www.braintreepaymentsolutions.com/docs/ruby/general/validation_errors
2
3
  class ValidationError
3
4
  include BaseModule
4
5
 
@@ -1,27 +1,5 @@
1
1
  module Braintree
2
- # A collection of validation errors.
3
- #
4
- # result = Braintree::Customer.create(
5
- # :email => "invalid",
6
- # :credit_card => {
7
- # :number => "invalidnumber",
8
- # :billing_address => {
9
- # :country_name => "invalid"
10
- # }
11
- # }
12
- # )
13
- # result.success?
14
- # #=> false
15
- # result.errors.for(:customer).on(:email)
16
- # #=> [#<Braintree::ValidationError (81604) Email is an invalid format.>]
17
- # result.errors.for(:customer).for(:credit_card).on(:number)
18
- # #=> [#<Braintree::ValidationError (81715) Credit card number is invalid.>]
19
- # result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_name)
20
- # #=> [#<Braintree::ValidationError (91803) Country name is not an accepted country.>]
21
- #
22
- # == More Information
23
- #
24
- # For more detailed documentation on ValidationErrors, see http://www.braintreepaymentsolutions.com/gateway/validation-errors
2
+ # See http://www.braintreepaymentsolutions.com/docs/ruby/general/validation_errors
25
3
  class ValidationErrorCollection
26
4
  include Enumerable
27
5
 
@@ -60,6 +38,10 @@ module Braintree
60
38
  @nested[nested_key]
61
39
  end
62
40
 
41
+ def for_index(index)
42
+ self.for("index_#{index}".to_sym)
43
+ end
44
+
63
45
  def inspect # :nodoc:
64
46
  "#<#{self.class} errors#{_inner_inspect}>"
65
47
  end
@@ -1,8 +1,8 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 2
4
- Minor = 4
5
- Tiny = 0
4
+ Minor = 5
5
+ Tiny = 1
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
8
8
  end
@@ -1,7 +1,7 @@
1
1
  # Portions of this code were copied and modified from Ruby on Rails, released
2
2
  # under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson
3
3
  module Braintree
4
- module Xml
4
+ module Xml # :nodoc:
5
5
  CONTENT_ROOT = '__content__'
6
6
 
7
7
  module Parser # :nodoc:
@@ -1,8 +1,8 @@
1
1
  # Portions of this code were copied and modified from Ruby on Rails, released
2
2
  # under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson
3
3
  module Braintree
4
- module Xml
5
- module Rexml
4
+ module Xml # :nodoc:
5
+ module Rexml # :nodoc:
6
6
 
7
7
  CONTENT_KEY = '__content__'.freeze
8
8
 
@@ -0,0 +1,532 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ describe Braintree::AdvancedSearch do
4
+ before(:each) do
5
+ @credit_card = Braintree::Customer.create!(
6
+ :credit_card => {
7
+ :number => Braintree::Test::CreditCardNumbers::Visa,
8
+ :expiration_date => "05/2010"
9
+ }
10
+ ).credit_cards[0]
11
+ end
12
+
13
+ context "text_fields" do
14
+ it "is" do
15
+ id = rand(36**8).to_s(36)
16
+ subscription1 = Braintree::Subscription.create(
17
+ :payment_method_token => @credit_card.token,
18
+ :plan_id => SpecHelper::TriallessPlan[:id],
19
+ :id => "subscription1_#{id}"
20
+ ).subscription
21
+
22
+ subscription2 = Braintree::Subscription.create(
23
+ :payment_method_token => @credit_card.token,
24
+ :plan_id => SpecHelper::TriallessPlan[:id],
25
+ :id => "subscription2_#{id}"
26
+ ).subscription
27
+
28
+ collection = Braintree::Subscription.search do |search|
29
+ search.id.is "subscription1_#{id}"
30
+ end
31
+
32
+ collection.should include(subscription1)
33
+ collection.should_not include(subscription2)
34
+ end
35
+
36
+ it "is_not" do
37
+ id = rand(36**8).to_s(36)
38
+ subscription1 = Braintree::Subscription.create(
39
+ :payment_method_token => @credit_card.token,
40
+ :plan_id => SpecHelper::TriallessPlan[:id],
41
+ :price => "11",
42
+ :id => "subscription1_#{id}"
43
+ ).subscription
44
+
45
+ subscription2 = Braintree::Subscription.create(
46
+ :payment_method_token => @credit_card.token,
47
+ :plan_id => SpecHelper::TriallessPlan[:id],
48
+ :price => "11",
49
+ :id => "subscription2_#{id}"
50
+ ).subscription
51
+
52
+ collection = Braintree::Subscription.search do |search|
53
+ search.id.is_not "subscription1_#{id}"
54
+ search.price.is "11"
55
+ end
56
+
57
+ collection.should_not include(subscription1)
58
+ collection.should include(subscription2)
59
+ end
60
+
61
+ it "starts_with" do
62
+ id = rand(36**8).to_s(36)
63
+ subscription1 = Braintree::Subscription.create(
64
+ :payment_method_token => @credit_card.token,
65
+ :plan_id => SpecHelper::TriallessPlan[:id],
66
+ :id => "subscription1_#{id}"
67
+ ).subscription
68
+
69
+ subscription2 = Braintree::Subscription.create(
70
+ :payment_method_token => @credit_card.token,
71
+ :plan_id => SpecHelper::TriallessPlan[:id],
72
+ :id => "subscription2_#{id}"
73
+ ).subscription
74
+
75
+ collection = Braintree::Subscription.search do |search|
76
+ search.id.starts_with "subscription1_"
77
+ end
78
+
79
+ collection.should include(subscription1)
80
+ collection.should_not include(subscription2)
81
+ end
82
+
83
+ it "ends_with" do
84
+ id = rand(36**8).to_s(36)
85
+ subscription1 = Braintree::Subscription.create(
86
+ :payment_method_token => @credit_card.token,
87
+ :plan_id => SpecHelper::TriallessPlan[:id],
88
+ :id => "subscription1_#{id}"
89
+ ).subscription
90
+
91
+ subscription2 = Braintree::Subscription.create(
92
+ :payment_method_token => @credit_card.token,
93
+ :plan_id => SpecHelper::TriallessPlan[:id],
94
+ :id => "subscription2_#{id}"
95
+ ).subscription
96
+
97
+ collection = Braintree::Subscription.search do |search|
98
+ search.id.ends_with "1_#{id}"
99
+ end
100
+
101
+ collection.should include(subscription1)
102
+ collection.should_not include(subscription2)
103
+ end
104
+
105
+ it "contains" do
106
+ id = rand(36**8).to_s(36)
107
+ subscription1 = Braintree::Subscription.create(
108
+ :payment_method_token => @credit_card.token,
109
+ :plan_id => SpecHelper::TriallessPlan[:id],
110
+ :id => "subscription1_#{id}"
111
+ ).subscription
112
+
113
+ subscription2 = Braintree::Subscription.create(
114
+ :payment_method_token => @credit_card.token,
115
+ :plan_id => SpecHelper::TriallessPlan[:id],
116
+ :id => "subscription2_#{id}"
117
+ ).subscription
118
+
119
+ collection = Braintree::Subscription.search do |search|
120
+ search.id.contains "scription1_"
121
+ end
122
+
123
+ collection.should include(subscription1)
124
+ collection.should_not include(subscription2)
125
+ end
126
+ end
127
+
128
+ context "multiple_value_field" do
129
+ context "in" do
130
+ it "matches all values if none are specified" do
131
+ subscription1 = Braintree::Subscription.create(
132
+ :payment_method_token => @credit_card.token,
133
+ :plan_id => SpecHelper::TriallessPlan[:id],
134
+ :price => "12"
135
+ ).subscription
136
+
137
+ subscription2 = Braintree::Subscription.create(
138
+ :payment_method_token => @credit_card.token,
139
+ :plan_id => SpecHelper::TriallessPlan[:id],
140
+ :price => "12"
141
+ ).subscription
142
+
143
+ Braintree::Subscription.cancel(subscription2.id)
144
+
145
+ collection = Braintree::Subscription.search do |search|
146
+ search.plan_id.is SpecHelper::TriallessPlan[:id]
147
+ search.price.is "12"
148
+ end
149
+
150
+ collection.should include(subscription1)
151
+ collection.should include(subscription2)
152
+ end
153
+
154
+ it "returns only matching results" do
155
+ subscription1 = Braintree::Subscription.create(
156
+ :payment_method_token => @credit_card.token,
157
+ :plan_id => SpecHelper::TriallessPlan[:id],
158
+ :price => "13"
159
+ ).subscription
160
+
161
+ subscription2 = Braintree::Subscription.create(
162
+ :payment_method_token => @credit_card.token,
163
+ :plan_id => SpecHelper::TriallessPlan[:id],
164
+ :price => "13"
165
+ ).subscription
166
+
167
+ Braintree::Subscription.cancel(subscription2.id)
168
+
169
+ collection = Braintree::Subscription.search do |search|
170
+ search.status.in Braintree::Subscription::Status::Active
171
+ search.price.is "13"
172
+ end
173
+
174
+ collection.should include(subscription1)
175
+ collection.should_not include(subscription2)
176
+ end
177
+
178
+ it "returns only matching results given an argument list" do
179
+ subscription1 = Braintree::Subscription.create(
180
+ :payment_method_token => @credit_card.token,
181
+ :plan_id => SpecHelper::TriallessPlan[:id],
182
+ :price => "14"
183
+ ).subscription
184
+
185
+ subscription2 = Braintree::Subscription.create(
186
+ :payment_method_token => @credit_card.token,
187
+ :plan_id => SpecHelper::TriallessPlan[:id],
188
+ :price => "14"
189
+ ).subscription
190
+
191
+ Braintree::Subscription.cancel(subscription2.id)
192
+
193
+ collection = Braintree::Subscription.search do |search|
194
+ search.status.in Braintree::Subscription::Status::Active, Braintree::Subscription::Status::Canceled
195
+ search.price.is "14"
196
+ end
197
+
198
+ collection.should include(subscription1)
199
+ collection.should include(subscription2)
200
+ end
201
+
202
+ describe "is" do
203
+ it "accepts single argument" do
204
+ subscription1 = Braintree::Subscription.create(
205
+ :payment_method_token => @credit_card.token,
206
+ :plan_id => SpecHelper::TriallessPlan[:id],
207
+ :price => "15"
208
+ ).subscription
209
+
210
+ subscription2 = Braintree::Subscription.create(
211
+ :payment_method_token => @credit_card.token,
212
+ :plan_id => SpecHelper::TriallessPlan[:id],
213
+ :price => "15"
214
+ ).subscription
215
+
216
+ Braintree::Subscription.cancel(subscription2.id)
217
+
218
+ collection = Braintree::Subscription.search do |search|
219
+ search.status.is Braintree::Subscription::Status::Active
220
+ search.price.is "15"
221
+ end
222
+
223
+ collection.should include(subscription1)
224
+ collection.should_not include(subscription2)
225
+ end
226
+ end
227
+
228
+ it "returns only matching results given an array" do
229
+ subscription1 = Braintree::Subscription.create(
230
+ :payment_method_token => @credit_card.token,
231
+ :plan_id => SpecHelper::TriallessPlan[:id],
232
+ :price => "16"
233
+ ).subscription
234
+
235
+ subscription2 = Braintree::Subscription.create(
236
+ :payment_method_token => @credit_card.token,
237
+ :plan_id => SpecHelper::TriallessPlan[:id],
238
+ :price => "16"
239
+ ).subscription
240
+
241
+ Braintree::Subscription.cancel(subscription2.id)
242
+
243
+ collection = Braintree::Subscription.search do |search|
244
+ search.status.in [Braintree::Subscription::Status::Active, Braintree::Subscription::Status::Canceled]
245
+ search.price.is "16"
246
+ end
247
+
248
+ collection.should include(subscription1)
249
+ collection.should include(subscription2)
250
+ end
251
+
252
+ it "returns expired subscriptions" do
253
+ collection = Braintree::Subscription.search do |search|
254
+ search.status.in [Braintree::Subscription::Status::Expired]
255
+ end
256
+
257
+ collection.maximum_size.should > 0
258
+ collection.all? { |subscription| subscription.status.should == Braintree::Subscription::Status::Expired }
259
+ end
260
+ end
261
+ end
262
+
263
+ context "multiple_value_or_text_field" do
264
+ describe "in" do
265
+ it "works for the in operator" do
266
+ subscription1 = Braintree::Subscription.create(
267
+ :payment_method_token => @credit_card.token,
268
+ :plan_id => SpecHelper::TriallessPlan[:id],
269
+ :price => "17"
270
+ ).subscription
271
+
272
+ subscription2 = Braintree::Subscription.create(
273
+ :payment_method_token => @credit_card.token,
274
+ :plan_id => SpecHelper::TrialPlan[:id],
275
+ :price => "17"
276
+ ).subscription
277
+
278
+ subscription3 = Braintree::Subscription.create(
279
+ :payment_method_token => @credit_card.token,
280
+ :plan_id => SpecHelper::AddOnDiscountPlan[:id],
281
+ :price => "17"
282
+ ).subscription
283
+
284
+ plan_ids = [SpecHelper::TriallessPlan[:id], SpecHelper::TrialPlan[:id]]
285
+ collection = Braintree::Subscription.search do |search|
286
+ search.plan_id.in plan_ids
287
+ search.price.is "17"
288
+ end
289
+
290
+ collection.maximum_size.should > 0
291
+ collection.all? { |subscription| plan_ids.include?(subscription.plan_id) }
292
+ end
293
+ end
294
+
295
+ context "a search with no matches" do
296
+ it "works" do
297
+ collection = Braintree::Subscription.search do |search|
298
+ search.plan_id.is "not_a_real_plan_id"
299
+ end
300
+
301
+ collection.maximum_size.should == 0
302
+ end
303
+ end
304
+
305
+ describe "is" do
306
+ it "returns resource collection with matching results" do
307
+ trialless_subscription = Braintree::Subscription.create(
308
+ :payment_method_token => @credit_card.token,
309
+ :plan_id => SpecHelper::TriallessPlan[:id],
310
+ :price => "18"
311
+ ).subscription
312
+
313
+ trial_subscription = Braintree::Subscription.create(
314
+ :payment_method_token => @credit_card.token,
315
+ :plan_id => SpecHelper::TrialPlan[:id],
316
+ :price => "18"
317
+ ).subscription
318
+
319
+ collection = Braintree::Subscription.search do |search|
320
+ search.plan_id.is SpecHelper::TriallessPlan[:id]
321
+ search.price.is "18"
322
+ end
323
+
324
+ collection.should include(trialless_subscription)
325
+ collection.should_not include(trial_subscription)
326
+ end
327
+ end
328
+
329
+ describe "is_not" do
330
+ it "returns resource collection without matching results" do
331
+ trialless_subscription = Braintree::Subscription.create(
332
+ :payment_method_token => @credit_card.token,
333
+ :plan_id => SpecHelper::TriallessPlan[:id],
334
+ :price => "19"
335
+ ).subscription
336
+
337
+ trial_subscription = Braintree::Subscription.create(
338
+ :payment_method_token => @credit_card.token,
339
+ :plan_id => SpecHelper::TrialPlan[:id],
340
+ :price => "19"
341
+ ).subscription
342
+
343
+ collection = Braintree::Subscription.search do |search|
344
+ search.plan_id.is_not SpecHelper::TriallessPlan[:id]
345
+ search.price.is "19"
346
+ end
347
+
348
+ collection.should_not include(trialless_subscription)
349
+ collection.should include(trial_subscription)
350
+ end
351
+ end
352
+
353
+ describe "ends_with" do
354
+ it "returns resource collection with matching results" do
355
+ trialless_subscription = Braintree::Subscription.create(
356
+ :payment_method_token => @credit_card.token,
357
+ :plan_id => SpecHelper::TriallessPlan[:id],
358
+ :price => "20"
359
+ ).subscription
360
+
361
+ trial_subscription = Braintree::Subscription.create(
362
+ :payment_method_token => @credit_card.token,
363
+ :plan_id => SpecHelper::TrialPlan[:id],
364
+ :price => "20"
365
+ ).subscription
366
+
367
+ collection = Braintree::Subscription.search do |search|
368
+ search.plan_id.ends_with "trial_plan"
369
+ search.price.is "20"
370
+ end
371
+
372
+ collection.should include(trial_subscription)
373
+ collection.should_not include(trialless_subscription)
374
+ end
375
+ end
376
+
377
+ describe "starts_with" do
378
+ it "returns resource collection with matching results" do
379
+ trialless_subscription = Braintree::Subscription.create(
380
+ :payment_method_token => @credit_card.token,
381
+ :plan_id => SpecHelper::TriallessPlan[:id],
382
+ :price => "21"
383
+ ).subscription
384
+
385
+ trial_subscription = Braintree::Subscription.create(
386
+ :payment_method_token => @credit_card.token,
387
+ :plan_id => SpecHelper::TrialPlan[:id],
388
+ :price => "21"
389
+ ).subscription
390
+
391
+ collection = Braintree::Subscription.search do |search|
392
+ search.plan_id.starts_with "integration_trial_p"
393
+ search.price.is "21"
394
+ end
395
+
396
+ collection.should include(trial_subscription)
397
+ collection.should_not include(trialless_subscription)
398
+ end
399
+ end
400
+
401
+ describe "contains" do
402
+ it "returns resource collection with matching results" do
403
+ trialless_subscription = Braintree::Subscription.create(
404
+ :payment_method_token => @credit_card.token,
405
+ :plan_id => SpecHelper::TriallessPlan[:id],
406
+ :price => "22"
407
+ ).subscription
408
+
409
+ trial_subscription = Braintree::Subscription.create(
410
+ :payment_method_token => @credit_card.token,
411
+ :plan_id => SpecHelper::TrialPlan[:id],
412
+ :price => "22"
413
+ ).subscription
414
+
415
+ collection = Braintree::Subscription.search do |search|
416
+ search.plan_id.contains "trial_p"
417
+ search.price.is "22"
418
+ end
419
+
420
+ collection.should include(trial_subscription)
421
+ collection.should_not include(trialless_subscription)
422
+ end
423
+ end
424
+ end
425
+
426
+ context "range_field" do
427
+ it "is" do
428
+ subscription_500 = Braintree::Subscription.create(
429
+ :payment_method_token => @credit_card.token,
430
+ :plan_id => SpecHelper::TriallessPlan[:id],
431
+ :price => "5.00"
432
+ ).subscription
433
+
434
+ subscription_501 = Braintree::Subscription.create(
435
+ :payment_method_token => @credit_card.token,
436
+ :plan_id => SpecHelper::TrialPlan[:id],
437
+ :price => "5.01"
438
+ ).subscription
439
+
440
+ collection = Braintree::Subscription.search do |search|
441
+ search.price.is "5.00"
442
+ end
443
+
444
+ collection.should include(subscription_500)
445
+ collection.should_not include(subscription_501)
446
+ end
447
+
448
+ it "<=" do
449
+ subscription_499 = Braintree::Subscription.create(
450
+ :payment_method_token => @credit_card.token,
451
+ :plan_id => SpecHelper::TrialPlan[:id],
452
+ :price => "4.99"
453
+ ).subscription
454
+
455
+ subscription_500 = Braintree::Subscription.create(
456
+ :payment_method_token => @credit_card.token,
457
+ :plan_id => SpecHelper::TriallessPlan[:id],
458
+ :price => "5.00"
459
+ ).subscription
460
+
461
+ subscription_501 = Braintree::Subscription.create(
462
+ :payment_method_token => @credit_card.token,
463
+ :plan_id => SpecHelper::TrialPlan[:id],
464
+ :price => "5.01"
465
+ ).subscription
466
+
467
+ collection = Braintree::Subscription.search do |search|
468
+ search.price <= "5.00"
469
+ end
470
+
471
+ collection.should include(subscription_499)
472
+ collection.should include(subscription_500)
473
+ collection.should_not include(subscription_501)
474
+ end
475
+
476
+ it ">=" do
477
+ subscription_499 = Braintree::Subscription.create(
478
+ :payment_method_token => @credit_card.token,
479
+ :plan_id => SpecHelper::TrialPlan[:id],
480
+ :price => "999.99"
481
+ ).subscription
482
+
483
+ subscription_500 = Braintree::Subscription.create(
484
+ :payment_method_token => @credit_card.token,
485
+ :plan_id => SpecHelper::TriallessPlan[:id],
486
+ :price => "1000.00"
487
+ ).subscription
488
+
489
+ subscription_501 = Braintree::Subscription.create(
490
+ :payment_method_token => @credit_card.token,
491
+ :plan_id => SpecHelper::TrialPlan[:id],
492
+ :price => "1000.01"
493
+ ).subscription
494
+
495
+ collection = Braintree::Subscription.search do |search|
496
+ search.price >= "1000.00"
497
+ end
498
+
499
+ collection.should_not include(subscription_499)
500
+ collection.should include(subscription_500)
501
+ collection.should include(subscription_501)
502
+ end
503
+
504
+ it "between" do
505
+ subscription_499 = Braintree::Subscription.create(
506
+ :payment_method_token => @credit_card.token,
507
+ :plan_id => SpecHelper::TrialPlan[:id],
508
+ :price => "4.99"
509
+ ).subscription
510
+
511
+ subscription_500 = Braintree::Subscription.create(
512
+ :payment_method_token => @credit_card.token,
513
+ :plan_id => SpecHelper::TriallessPlan[:id],
514
+ :price => "5.00"
515
+ ).subscription
516
+
517
+ subscription_502 = Braintree::Subscription.create(
518
+ :payment_method_token => @credit_card.token,
519
+ :plan_id => SpecHelper::TrialPlan[:id],
520
+ :price => "5.02"
521
+ ).subscription
522
+
523
+ collection = Braintree::Subscription.search do |search|
524
+ search.price.between "4.99", "5.01"
525
+ end
526
+
527
+ collection.should include(subscription_499)
528
+ collection.should include(subscription_500)
529
+ collection.should_not include(subscription_502)
530
+ end
531
+ end
532
+ end