fake_braintree 0.4 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90895aa7f5953a1df73fedda78c56cf804b119f5
4
- data.tar.gz: 2f12cc8250442c5f6a6de12a6e40cf22f3f44905
3
+ metadata.gz: e490dbbce81677c05e0eb73532ea5471db948dd7
4
+ data.tar.gz: b5090bfd54c5118b61912bacdc9bcf39956c9109
5
5
  SHA512:
6
- metadata.gz: 86fd2e92a281e532424652cb7d80f2bacaf82fc7d2f75ae120d7cbe3bc1398b63fa18a05987c659e9694cbdde726d893d70c54b0c8f369e457baa09ca37d707f
7
- data.tar.gz: 64eb83bd4581fc26e508aad73dca9b60d9a90a1df6465c62ede7495b1ed4d14fc8c9a7262a40e8267f44e60e6a46603ec80fa6fd3182d094c33d139f620f62f9
6
+ metadata.gz: 3a46b7284f3489ec49d8098f651e83c72f0ce2850f372ce51fcce885b15dced400a5615f5168eabb4974ccde8fb210358a71a8732fc2af25d23c27b184c5bb01
7
+ data.tar.gz: 968a51beab295415d2098710cebe4f327b3f1847f20d6daa6301284df6adf1c7635b318ae137544a47bf6679d1a06e098e00d4276453ab037f6343f2c9061aa9
@@ -1,6 +1,9 @@
1
1
  rvm:
2
2
  - 1.9.2
3
3
  - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - 2.1.1
4
7
  before_install:
5
8
  - gem update --system
6
9
  branches:
data/Gemfile CHANGED
@@ -2,3 +2,12 @@ source 'http://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in fake_braintree.gemspec
4
4
  gemspec
5
+
6
+ # Capybara 2.1.0 requires 1.9.3+ so we install a version that works with
7
+ # every Ruby version we test against. This can be removed if we stop testing
8
+ # against 1.9.2.
9
+ gem 'capybara', '~> 2.0.3'
10
+
11
+ if RUBY_VERSION == '1.9.2'
12
+ gem 'activesupport', '< 4.0'
13
+ end
data/NEWS.md CHANGED
@@ -1,4 +1,8 @@
1
- # HEAD (unreleased)
1
+ # 0.4.1
2
+
3
+ * Add support for `Braintree::Subscription.retry_charge`
4
+
5
+ # 0.4
2
6
 
3
7
  * Add support for `Braintree::Address.create`
4
8
  * Add support for creating a card with an existing billing address (#45)
data/README.md CHANGED
@@ -14,34 +14,37 @@ of them (yet).
14
14
 
15
15
  ## Supported API methods
16
16
 
17
+ ### Address
18
+ * `Braintree::Address.create`
19
+
20
+ ### CreditCard
21
+ * `Braintree::CreditCard.create`
22
+ * `Braintree::CreditCard.find`
23
+ * `Braintree::CreditCard.sale`
24
+ * `Braintree::CreditCard.update`
25
+
17
26
  ### Customer
18
- * `Braintree::Customer.find`
19
27
  * `Braintree::Customer.create` (including adding add-ons and discounts)
20
- * `Braintree::Customer.update`
21
28
  * `Braintree::Customer.delete`
29
+ * `Braintree::Customer.find`
30
+ * `Braintree::Customer.update`
22
31
 
23
32
  ### Subscription
24
- * `Braintree::Subscription.find`
33
+ * `Braintree::Subscription.cancel`
25
34
  * `Braintree::Subscription.create`
35
+ * `Braintree::Subscription.find`
26
36
  * `Braintree::Subscription.update`
27
- * `Braintree::Subscription.cancel`
28
-
29
- ### CreditCard
30
- * `Braintree::CreditCard.find`
31
- * `Braintree::CreditCard.sale`
32
- * `Braintree::CreditCard.update`
37
+ * `Braintree::Subscription.retry_charge`
33
38
 
34
39
  ### Transaction
35
- * `Braintree::Transaction.sale`
40
+ * `Braintree::Transaction.find`
36
41
  * `Braintree::Transaction.refund`
42
+ * `Braintree::Transaction.sale`
37
43
  * `Braintree::Transaction.void`
38
44
 
39
45
  ### TransparentRedirect
40
- * `Braintree::TransparentRedirect.url`
41
46
  * `Braintree::TransparentRedirect.confirm` (only for creating customers)
42
-
43
- ### Address
44
- * `Braintree::Address.create`
47
+ * `Braintree::TransparentRedirect.url`
45
48
 
46
49
  ## Quick start
47
50
  Just require the library and you're good to go:
@@ -77,7 +80,7 @@ To use fake\_braintree with Spork, do this:
77
80
 
78
81
  # Gemfile
79
82
  group :test do
80
- gem 'fake_braintree', :require => false
83
+ gem 'fake_braintree', require: false
81
84
  end
82
85
 
83
86
  # spec/spec_helper.rb
@@ -147,10 +150,10 @@ call it with no arguments.
147
150
 
148
151
  Full example:
149
152
 
150
- transaction = FakeBraintree.generate_transaction(:amount => '20.00',
151
- :status => Braintree::Transaction::Status::Settled,
152
- :subscription_id => 'foobar',
153
- :created_at => Time.now + 60)
153
+ transaction = FakeBraintree.generate_transaction(amount: '20.00',
154
+ status: Braintree::Transaction::Status::Settled,
155
+ subscription_id: 'foobar',
156
+ created_at: Time.now + 60)
154
157
  p transaction
155
158
  # {
156
159
  # "status_history" =>
@@ -25,10 +25,6 @@ Gem::Specification.new do |s|
25
25
  s.add_dependency 'thin'
26
26
 
27
27
  s.add_development_dependency 'rspec', '~> 2.12.0'
28
- # Capybara 2.1.0 requires 1.9.3+ so we install a version that works with
29
- # every Ruby version we test against. This can be removed if we stop testing
30
- # against 1.9.2.
31
- s.add_development_dependency 'capybara', '~> 2.0.3'
32
28
  s.add_development_dependency 'bourne', '~> 1.3'
33
29
  s.add_development_dependency 'timecop', '~> 0.6'
34
30
  s.add_development_dependency 'rake'
@@ -18,7 +18,7 @@ module FakeBraintree
18
18
  end
19
19
 
20
20
  def response_for_updated_address
21
- gzipped_response(200, @hash.to_xml(:root => 'address'))
21
+ gzipped_response(200, @hash.to_xml(root: 'address'))
22
22
  end
23
23
 
24
24
  def set_up_address(address_hash_from_params, options)
@@ -34,7 +34,7 @@ module FakeBraintree
34
34
  end
35
35
 
36
36
  def to_xml
37
- @hash.to_xml(:root => 'credit_card')
37
+ @hash.to_xml(root: 'credit_card')
38
38
  end
39
39
 
40
40
  def valid_number?
@@ -66,7 +66,7 @@ module FakeBraintree
66
66
  end
67
67
 
68
68
  def response_for_updated_card
69
- gzipped_response(200, @hash.to_xml(:root => 'credit_card'))
69
+ gzipped_response(200, @hash.to_xml(root: 'credit_card'))
70
70
  end
71
71
 
72
72
  def credit_card_exists_in_registry?
@@ -78,14 +78,14 @@ module FakeBraintree
78
78
  end
79
79
 
80
80
  def response_for_card_not_found
81
- gzipped_response(404, FakeBraintree.failure_response.to_xml(:root => 'api_error_response'))
81
+ gzipped_response(404, FakeBraintree.failure_response.to_xml(root: 'api_error_response'))
82
82
  end
83
83
 
84
84
  def response_for_invalid_card
85
85
  gzipped_response(422, FakeBraintree.failure_response.merge(
86
- 'params' => {:credit_card => @hash}
86
+ 'params' => {credit_card: @hash}
87
87
  ).
88
- to_xml(:root => 'api_error_response'))
88
+ to_xml(root: 'api_error_response'))
89
89
  end
90
90
 
91
91
  def expiration_month
@@ -104,7 +104,7 @@ module FakeBraintree
104
104
 
105
105
  def set_default_credit_card(credit_card_hash)
106
106
  if credit_card_hash
107
- CreditCard.new(credit_card_hash, :customer_id => @customer_hash['id'], :make_default => true).update
107
+ CreditCard.new(credit_card_hash, customer_id: @customer_hash['id'], make_default: true).update
108
108
  end
109
109
  end
110
110
 
@@ -153,11 +153,11 @@ module FakeBraintree
153
153
  end
154
154
 
155
155
  def response_for_created_customer(hash)
156
- gzipped_response(201, hash.to_xml(:root => 'customer'))
156
+ gzipped_response(201, hash.to_xml(root: 'customer'))
157
157
  end
158
158
 
159
159
  def response_for_updated_customer(hash)
160
- gzipped_response(200, hash.to_xml(:root => 'customer'))
160
+ gzipped_response(200, hash.to_xml(root: 'customer'))
161
161
  end
162
162
 
163
163
  def response_for_invalid_card
@@ -169,7 +169,7 @@ module FakeBraintree
169
169
  end
170
170
 
171
171
  def failure_response(code)
172
- gzipped_response(code, FakeBraintree.failure_response(credit_card_number).to_xml(:root => 'api_error_response'))
172
+ gzipped_response(code, FakeBraintree.failure_response(credit_card_number).to_xml(root: 'api_error_response'))
173
173
  end
174
174
 
175
175
  def customer_id
@@ -19,9 +19,9 @@ module FakeBraintree
19
19
 
20
20
  def confirm
21
21
  if @kind == 'create_customer'
22
- Customer.new(@params['customer'], {:merchant_id => @merchant_id}).create
22
+ Customer.new(@params['customer'], {merchant_id: @merchant_id}).create
23
23
  elsif @kind == 'create_payment_method'
24
- credit_card_options = {:merchant_id => @merchant_id}
24
+ credit_card_options = {merchant_id: @merchant_id}
25
25
  credit_card_options.merge!(@transparent_data['credit_card'].fetch('options', {}))
26
26
 
27
27
  credit_card_options.symbolize_keys!
@@ -16,7 +16,7 @@ class FakeBraintree::Server
16
16
  def with_thin_runner
17
17
  default_server_process = Capybara.server
18
18
  Capybara.server do |app, port|
19
- Rack::Handler::Thin.run(app, :Port => port)
19
+ Rack::Handler::Thin.run(app, Port: port)
20
20
  end
21
21
  yield
22
22
  ensure
@@ -23,7 +23,7 @@ module FakeBraintree
23
23
  # Braintree::Customer.create
24
24
  post '/merchants/:merchant_id/customers' do
25
25
  customer_hash = hash_from_request_body_with_key('customer')
26
- options = {:merchant_id => params[:merchant_id]}
26
+ options = {merchant_id: params[:merchant_id]}
27
27
  Customer.new(customer_hash, options).create
28
28
  end
29
29
 
@@ -31,7 +31,7 @@ module FakeBraintree
31
31
  get '/merchants/:merchant_id/customers/:id' do
32
32
  customer = FakeBraintree.registry.customers[params[:id]]
33
33
  if customer
34
- gzipped_response(200, customer.to_xml(:root => 'customer'))
34
+ gzipped_response(200, customer.to_xml(root: 'customer'))
35
35
  else
36
36
  gzipped_response(404, {})
37
37
  end
@@ -40,28 +40,28 @@ module FakeBraintree
40
40
  # Braintree::Customer.update
41
41
  put '/merchants/:merchant_id/customers/:id' do
42
42
  customer_hash = hash_from_request_body_with_key('customer')
43
- options = {:id => params[:id], :merchant_id => params[:merchant_id]}
43
+ options = {id: params[:id], merchant_id: params[:merchant_id]}
44
44
  Customer.new(customer_hash, options).update
45
45
  end
46
46
 
47
47
  # Braintree::Customer.delete
48
48
  delete '/merchants/:merchant_id/customers/:id' do
49
49
  customer_hash = {}
50
- options = {:id => params[:id], :merchant_id => params[:merchant_id]}
50
+ options = {id: params[:id], merchant_id: params[:merchant_id]}
51
51
  Customer.new(customer_hash, options).delete
52
52
  end
53
53
 
54
54
  # Braintree::Address.create
55
55
  post "/merchants/:merchant_id/customers/:customer_id/addresses" do
56
56
  address_hash = hash_from_request_body_with_key('address')
57
- options = {:customer_id => params[:customer_id], :merchant_id => params[:merchant_id]}
57
+ options = {customer_id: params[:customer_id], merchant_id: params[:merchant_id]}
58
58
  Address.new(address_hash, options).create
59
59
  end
60
60
 
61
61
  # Braintree::Subscription.create
62
62
  post '/merchants/:merchant_id/subscriptions' do
63
63
  subscription_hash = hash_from_request_body_with_key('subscription')
64
- options = {:merchant_id => params[:merchant_id]}
64
+ options = {merchant_id: params[:merchant_id]}
65
65
  Subscription.new(subscription_hash, options).create
66
66
  end
67
67
 
@@ -69,7 +69,7 @@ module FakeBraintree
69
69
  get '/merchants/:merchant_id/subscriptions/:id' do
70
70
  subscription = FakeBraintree.registry.subscriptions[params[:id]]
71
71
  if subscription
72
- gzipped_response(200, subscription.to_xml(:root => 'subscription'))
72
+ gzipped_response(200, subscription.to_xml(root: 'subscription'))
73
73
  else
74
74
  gzipped_response(404, {})
75
75
  end
@@ -78,14 +78,14 @@ module FakeBraintree
78
78
  # Braintree::Subscription.update
79
79
  put '/merchants/:merchant_id/subscriptions/:id' do
80
80
  subscription_hash = hash_from_request_body_with_key('subscription')
81
- options = {:id => params[:id], :merchant_id => params[:merchant_id]}
81
+ options = {id: params[:id], merchant_id: params[:merchant_id]}
82
82
  Subscription.new(subscription_hash, options).update
83
83
  end
84
84
 
85
85
  # Braintree::Subscription.cancel
86
86
  put '/merchants/:merchant_id/subscriptions/:id/cancel' do
87
87
  updates = {'status' => Braintree::Subscription::Status::Canceled}
88
- options = {:id => params[:id], :merchant_id => params[:merchant_id]}
88
+ options = {id: params[:id], merchant_id: params[:merchant_id]}
89
89
  Subscription.new(updates, options).update
90
90
  end
91
91
 
@@ -93,7 +93,7 @@ module FakeBraintree
93
93
  get '/merchants/:merchant_id/payment_methods/:credit_card_token' do
94
94
  credit_card = FakeBraintree.registry.credit_cards[params[:credit_card_token]]
95
95
  if credit_card
96
- gzipped_response(200, credit_card.to_xml(:root => 'credit_card'))
96
+ gzipped_response(200, credit_card.to_xml(root: 'credit_card'))
97
97
  else
98
98
  gzipped_response(404, {})
99
99
  end
@@ -103,14 +103,14 @@ module FakeBraintree
103
103
  put '/merchants/:merchant_id/payment_methods/:credit_card_token' do
104
104
  credit_card = FakeBraintree.registry.credit_cards[params[:credit_card_token]]
105
105
  updates = hash_from_request_body_with_key('credit_card')
106
- options = {:token => params[:credit_card_token], :merchant_id => params[:merchant_id]}
106
+ options = {token: params[:credit_card_token], merchant_id: params[:merchant_id]}
107
107
  CreditCard.new(updates, options).update
108
108
  end
109
109
 
110
110
  # Braintree::CreditCard.create
111
111
  post '/merchants/:merchant_id/payment_methods' do
112
112
  credit_card_hash = hash_from_request_body_with_key('credit_card')
113
- options = {:merchant_id => params[:merchant_id]}
113
+ options = {merchant_id: params[:merchant_id]}
114
114
 
115
115
  if credit_card_hash['options']
116
116
  options.merge!(credit_card_hash.delete('options')).symbolize_keys!
@@ -123,7 +123,7 @@ module FakeBraintree
123
123
  # Braintree::CreditCard.sale
124
124
  post '/merchants/:merchant_id/transactions' do
125
125
  if FakeBraintree.decline_all_cards?
126
- gzipped_response(422, FakeBraintree.create_failure.to_xml(:root => 'api_error_response'))
126
+ gzipped_response(422, FakeBraintree.create_failure.to_xml(root: 'api_error_response'))
127
127
  else
128
128
  transaction = hash_from_request_body_with_key('transaction')
129
129
  transaction_id = md5("#{params[:merchant_id]}#{Time.now.to_f}")
@@ -134,7 +134,7 @@ module FakeBraintree
134
134
  end
135
135
  transaction_response = {'id' => transaction_id, 'amount' => transaction['amount'], 'status' => status, 'type' => 'sale'}
136
136
  FakeBraintree.registry.transactions[transaction_id] = transaction_response
137
- gzipped_response(200, transaction_response.to_xml(:root => 'transaction'))
137
+ gzipped_response(200, transaction_response.to_xml(root: 'transaction'))
138
138
  end
139
139
  end
140
140
 
@@ -142,7 +142,7 @@ module FakeBraintree
142
142
  get '/merchants/:merchant_id/transactions/:transaction_id' do
143
143
  transaction = FakeBraintree.registry.transactions[params[:transaction_id]]
144
144
  if transaction
145
- gzipped_response(200, transaction.to_xml(:root => 'transaction'))
145
+ gzipped_response(200, transaction.to_xml(root: 'transaction'))
146
146
  else
147
147
  gzipped_response(404, {})
148
148
  end
@@ -154,7 +154,18 @@ module FakeBraintree
154
154
  transaction_id = md5('#{params[:merchant_id]}#{Time.now.to_f}')
155
155
  transaction_response = {'id' => transaction_id, 'amount' => transaction['amount'], 'type' => 'credit'}
156
156
  FakeBraintree.registry.transactions[transaction_id] = transaction_response
157
- gzipped_response(200, transaction_response.to_xml(:root => 'transaction'))
157
+ gzipped_response(200, transaction_response.to_xml(root: 'transaction'))
158
+ end
159
+
160
+
161
+ put '/merchants/:merchant_id/transactions/:transaction_id/submit_for_settlement' do
162
+ transaction = FakeBraintree.registry.transactions[params[:transaction_id]]
163
+ transaction_response = {'id' => transaction['id'],
164
+ 'type' => transaction['sale'],
165
+ 'amount' => transaction['amount'],
166
+ 'status' => Braintree::Transaction::Status::SubmittedForSettlement}
167
+ FakeBraintree.registry.transactions[transaction['id']] = transaction_response
168
+ gzipped_response(200, transaction_response.to_xml(root: 'transaction'))
158
169
  end
159
170
 
160
171
  # Braintree::Transaction.void
@@ -165,7 +176,7 @@ module FakeBraintree
165
176
  'amount' => transaction['amount'],
166
177
  'status' => Braintree::Transaction::Status::Voided}
167
178
  FakeBraintree.registry.transactions[transaction['id']] = transaction_response
168
- gzipped_response(200, transaction_response.to_xml(:root => 'transaction'))
179
+ gzipped_response(200, transaction_response.to_xml(root: 'transaction'))
169
180
  end
170
181
 
171
182
  # Braintree::TransparentRedirect.url
@@ -3,9 +3,10 @@ module FakeBraintree
3
3
  include Helpers
4
4
 
5
5
  def initialize(subscription_hash_from_params, options)
6
+ id = subscription_hash_from_params['id'] || options[:id]
6
7
  @subscription_hash = subscription_hash_from_params.merge(
7
8
  'merchant_id' => options[:merchant_id],
8
- 'id' => options[:id]
9
+ 'id' => id
9
10
  )
10
11
  set_subscription_id
11
12
  set_subscription_status
@@ -98,7 +99,7 @@ module FakeBraintree
98
99
  end
99
100
 
100
101
  def response_for_created_subscription(hash)
101
- gzipped_response(201, hash.to_xml(:root => 'subscription'))
102
+ gzipped_response(201, hash.to_xml(root: 'subscription'))
102
103
  end
103
104
 
104
105
  def response_for_subscription_not_found
@@ -106,7 +107,7 @@ module FakeBraintree
106
107
  end
107
108
 
108
109
  def response_for_created_subscription(hash)
109
- gzipped_response(201, hash.to_xml(:root => 'subscription'))
110
+ gzipped_response(201, hash.to_xml(root: 'subscription'))
110
111
  end
111
112
  end
112
113
  end
@@ -1,3 +1,3 @@
1
1
  module FakeBraintree
2
- VERSION = '0.4'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe "Braintree::Address.create" do
4
4
  it "successfully creates address with valid data" do
5
5
  result = create_customer
6
- result = Braintree::Address.create(:customer_id => result.customer.id, :postal_code => 30339)
6
+ result = Braintree::Address.create(customer_id: result.customer.id, postal_code: 30339)
7
7
  result.should be_success
8
8
  end
9
9
  end
@@ -2,21 +2,23 @@ require 'spec_helper'
2
2
 
3
3
  describe 'Braintree::CreditCard.find' do
4
4
  it 'gets the correct credit card' do
5
- credit_card = Braintree::CreditCard.find(token)
5
+ month = '04'
6
+ year = '2016'
7
+ credit_card = Braintree::CreditCard.find(token_for(month, year))
6
8
 
7
9
  credit_card.last_4.should == TEST_CC_NUMBER[-4,4]
8
10
  credit_card.expiration_month.should == month
9
11
  credit_card.expiration_year.should == year
10
12
  end
11
13
 
12
- let(:month) { '04' }
13
- let(:year) { '2016' }
14
- let(:token) { braintree_credit_card_token(TEST_CC_NUMBER, [month, year].join('/')) }
14
+ def token_for(month, year)
15
+ braintree_credit_card_token(TEST_CC_NUMBER, [month, year].join('/'))
16
+ end
15
17
  end
16
18
 
17
19
  describe 'Braintree::CreditCard.sale' do
18
20
  it 'successfully creates a sale' do
19
- result = Braintree::CreditCard.sale(cc_token, :amount => 10.00)
21
+ result = Braintree::CreditCard.sale(cc_token, amount: 10.00)
20
22
  result.should be_success
21
23
  Braintree::Transaction.find(result.transaction.id).should be
22
24
  end
@@ -24,22 +26,6 @@ end
24
26
 
25
27
 
26
28
  describe 'Braintree::CreditCard.create' do
27
- def build_credit_card_hash
28
- {
29
- :customer_id => @customer && @customer.id,
30
- :number => '4111111111111111',
31
- :cvv => '123',
32
- :token => 'token',
33
- :expiration_date => '07/2020',
34
- :billing_address => {
35
- :postal_code => '94110'
36
- },
37
- :options => {
38
- :make_default => true
39
- }
40
- }
41
- end
42
-
43
29
  it 'allows creating a credit card without a customer' do
44
30
  result = Braintree::CreditCard.create(build_credit_card_hash)
45
31
  result.should be_success
@@ -55,15 +41,15 @@ describe 'Braintree::CreditCard.create' do
55
41
  FakeBraintree.decline_all_cards!
56
42
  result = Braintree::CreditCard.create(build_credit_card_hash)
57
43
  result.should_not be_success
58
- expect { Braintree::CreditCard.find('token') }.to raise_exception Braintree::NotFoundError
44
+ expect { Braintree::CreditCard.find('token') }.to raise_error Braintree::NotFoundError
59
45
  FakeBraintree.clear!
60
46
  end
61
47
 
62
48
  it 'fails to create a credit card if verify_all_cards is set and card is invalid' do
63
49
  FakeBraintree.verify_all_cards!
64
- result = Braintree::CreditCard.create(build_credit_card_hash.merge(:number => '12345'))
50
+ result = Braintree::CreditCard.create(build_credit_card_hash.merge(number: '12345'))
65
51
  result.should_not be_success
66
- expect { Braintree::CreditCard.find('token') }.to raise_exception Braintree::NotFoundError
52
+ expect { Braintree::CreditCard.find('token') }.to raise_error Braintree::NotFoundError
67
53
  FakeBraintree.verify_all_cards = false
68
54
  end
69
55
 
@@ -71,7 +57,7 @@ describe 'Braintree::CreditCard.create' do
71
57
  result = Braintree::CreditCard.create(build_credit_card_hash)
72
58
  result.should be_success
73
59
  Braintree::Customer.find(@customer.id).credit_cards.last.token.should == 'token'
74
- Braintree::Customer.find(@customer.id).credit_cards.last.default?.should be_true
60
+ Braintree::Customer.find(@customer.id).credit_cards.last.should be_default
75
61
  Braintree::Customer.find(@customer.id).credit_cards.last.billing_address.postal_code.should == "94110"
76
62
  end
77
63
 
@@ -82,10 +68,26 @@ describe 'Braintree::CreditCard.create' do
82
68
  result.should be_success
83
69
  # Reload the customer
84
70
  @customer = Braintree::Customer.find(@customer.id)
85
- @customer.credit_cards.select {|c| c.default?}.length.should == 1
71
+ @customer.credit_cards.select(&:default?).length.should == 1
86
72
  @customer.credit_cards.length.should == 2
87
73
  end
88
74
  end
75
+
76
+ def build_credit_card_hash
77
+ {
78
+ customer_id: @customer && @customer.id,
79
+ number: '4111111111111111',
80
+ cvv: '123',
81
+ token: 'token',
82
+ expiration_date: '07/2020',
83
+ billing_address: {
84
+ postal_code: '94110'
85
+ },
86
+ options: {
87
+ make_default: true
88
+ }
89
+ }
90
+ end
89
91
  end
90
92
 
91
93
  describe 'Braintree::CreditCard.update' do
@@ -93,12 +95,12 @@ describe 'Braintree::CreditCard.update' do
93
95
  new_expiration_date = '08/2012'
94
96
  token = cc_token
95
97
 
96
- result = Braintree::CreditCard.update(token, :expiration_date => new_expiration_date)
98
+ result = Braintree::CreditCard.update(token, expiration_date: new_expiration_date)
97
99
  result.should be_success
98
100
  Braintree::CreditCard.find(token).expiration_date.should == new_expiration_date
99
101
  end
100
102
 
101
103
  it 'raises an error for a nonexistent credit card' do
102
- lambda { Braintree::CreditCard.update('foo', {:number => TEST_CC_NUMBER}) }.should raise_error(Braintree::NotFoundError)
104
+ expect { Braintree::CreditCard.update('foo', number: TEST_CC_NUMBER) }.to raise_error(Braintree::NotFoundError)
103
105
  end
104
106
  end