braintree-rails 1.3.0 → 1.4.0

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -1
  3. data/CHANGELOG.md +12 -0
  4. data/Gemfile.lock +48 -34
  5. data/braintree-rails.gemspec +7 -7
  6. data/lib/braintree_rails/address.rb +1 -1
  7. data/lib/braintree_rails/address_validator.rb +1 -1
  8. data/lib/braintree_rails/api_error.rb +1 -1
  9. data/lib/braintree_rails/billing_address.rb +5 -1
  10. data/lib/braintree_rails/business_details.rb +1 -1
  11. data/lib/braintree_rails/credit_card.rb +2 -2
  12. data/lib/braintree_rails/customer.rb +2 -2
  13. data/lib/braintree_rails/individual_details.rb +1 -1
  14. data/lib/braintree_rails/merchant_account.rb +6 -2
  15. data/lib/braintree_rails/model.rb +7 -9
  16. data/lib/braintree_rails/persistence.rb +2 -20
  17. data/lib/braintree_rails/shipping_address.rb +5 -1
  18. data/lib/braintree_rails/transaction.rb +5 -5
  19. data/lib/braintree_rails/transaction_validator.rb +1 -1
  20. data/lib/braintree_rails/validator.rb +1 -1
  21. data/lib/braintree_rails/version.rb +1 -1
  22. data/spec/fixtures/merchant_account.xml +1 -1
  23. data/spec/fixtures/transaction_error.xml +65 -20
  24. data/spec/integration/braintree_rails/address_integration_spec.rb +6 -6
  25. data/spec/integration/braintree_rails/credit_card_integration_spec.rb +17 -17
  26. data/spec/integration/braintree_rails/customer_integration_spec.rb +17 -17
  27. data/spec/integration/braintree_rails/merchant_account_integration_spec.rb +11 -11
  28. data/spec/integration/braintree_rails/transaction_integration_spec.rb +24 -25
  29. data/spec/integration/integration_spec_helper.rb +2 -1
  30. data/spec/spec_helper.rb +1 -0
  31. data/spec/support/helper.rb +16 -2
  32. data/spec/unit/braintree_rails/add_on_spec.rb +10 -11
  33. data/spec/unit/braintree_rails/add_ons_spec.rb +3 -3
  34. data/spec/unit/braintree_rails/address_details_spec.rb +3 -3
  35. data/spec/unit/braintree_rails/address_spec.rb +26 -26
  36. data/spec/unit/braintree_rails/addresses_spec.rb +7 -7
  37. data/spec/unit/braintree_rails/business_details_spec.rb +8 -8
  38. data/spec/unit/braintree_rails/configuration_spec.rb +6 -6
  39. data/spec/unit/braintree_rails/credit_card_spec.rb +76 -76
  40. data/spec/unit/braintree_rails/credit_cards_spec.rb +11 -11
  41. data/spec/unit/braintree_rails/customer_spec.rb +44 -44
  42. data/spec/unit/braintree_rails/discount_spec.rb +10 -11
  43. data/spec/unit/braintree_rails/discounts_spec.rb +3 -3
  44. data/spec/unit/braintree_rails/funding_details_spec.rb +12 -12
  45. data/spec/unit/braintree_rails/individual_details_spec.rb +5 -5
  46. data/spec/unit/braintree_rails/luhn_10_validator_spec.rb +5 -5
  47. data/spec/unit/braintree_rails/merchant_account_spec.rb +14 -14
  48. data/spec/unit/braintree_rails/plan_spec.rb +12 -12
  49. data/spec/unit/braintree_rails/subscription_spec.rb +53 -53
  50. data/spec/unit/braintree_rails/subscriptions_spec.rb +4 -5
  51. data/spec/unit/braintree_rails/transaction_spec.rb +67 -55
  52. data/spec/unit/braintree_rails/transactions_spec.rb +9 -9
  53. data/spec/unit/braintree_rails/validation_error_spec.rb +4 -4
  54. data/spec/unit/braintree_rails/validator_spec.rb +7 -7
  55. metadata +35 -17
@@ -13,7 +13,7 @@ describe 'Address Integration' do
13
13
  braintree_address = braintree_customer.addresses.first
14
14
 
15
15
  attributes.each do |key, value|
16
- braintree_address.send(key).should == value
16
+ expect(braintree_address.send(key)).to eq(value)
17
17
  end
18
18
  end
19
19
 
@@ -24,14 +24,14 @@ describe 'Address Integration' do
24
24
 
25
25
  braintree_customer = Braintree::Customer.find(customer.id)
26
26
  braintree_address = braintree_customer.addresses.first
27
- braintree_address.first_name.should == 'Foo'
27
+ expect(braintree_address.first_name).to eq('Foo')
28
28
 
29
29
  address.last_name = 'Bar'
30
30
  address.save!
31
31
 
32
32
  braintree_customer = Braintree::Customer.find(customer.id)
33
33
  braintree_address = braintree_customer.addresses.first
34
- braintree_address.last_name.should == 'Bar'
34
+ expect(braintree_address.last_name).to eq('Bar')
35
35
  end
36
36
 
37
37
  it 'should be able to destroy existing address' do
@@ -39,11 +39,11 @@ describe 'Address Integration' do
39
39
  address = customer.addresses.create!(address_hash)
40
40
  address.destroy
41
41
  expect { Braintree::Address.find(customer.id, address.id) }.to raise_error(Braintree::NotFoundError)
42
- address.should_not be_persisted
43
- address.should be_frozen
42
+ expect(address).to_not be_persisted
43
+ expect(address).to be_frozen
44
44
 
45
45
  address = customer.addresses.create!(address_hash)
46
46
  BraintreeRails::Address.delete(customer.id, address.id)
47
47
  expect { Braintree::Address.find(customer.id, address.id) }.to raise_error(Braintree::NotFoundError)
48
48
  end
49
- end
49
+ end
@@ -12,11 +12,11 @@ describe 'Credit Card Integration' do
12
12
  credit_card = BraintreeRails::CreditCard.new(braintree_customer.credit_cards.first.token)
13
13
 
14
14
  attributes.except(:number, :cvv, :billing_address).each do |key, value|
15
- credit_card.send(key).should == value
15
+ expect(credit_card.send(key)).to eq(value)
16
16
  end
17
17
 
18
18
  attributes[:billing_address].each do |key, value|
19
- credit_card.billing_address.send(key).should == value
19
+ expect(credit_card.billing_address.send(key)).to eq(value)
20
20
  end
21
21
  end
22
22
 
@@ -27,12 +27,12 @@ describe 'Credit Card Integration' do
27
27
 
28
28
  braintree_credit_card = Braintree::CreditCard.find(credit_card.id)
29
29
  attributes.except(:number, :cvv, :billing_address).each do |key, value|
30
- braintree_credit_card.send(key).should == value
30
+ expect(braintree_credit_card.send(key)).to eq(value)
31
31
  end
32
32
 
33
33
  braintree_address = braintree_credit_card.billing_address
34
34
  attributes[:billing_address].each do |key, value|
35
- braintree_address.send(key).should == value
35
+ expect(braintree_address.send(key)).to eq(value)
36
36
  end
37
37
  end
38
38
 
@@ -42,8 +42,8 @@ describe 'Credit Card Integration' do
42
42
 
43
43
  credit_card.update_attributes!(:cardholder_name => 'Foo Bar', :number => '4111111111111111', :options => {:verify_card => true}, :billing_address => address_hash.merge(:postal_code => '56789'))
44
44
  braintree_credit_card = Braintree::CreditCard.find(credit_card.id)
45
- braintree_credit_card.cardholder_name.should == 'Foo Bar'
46
- braintree_credit_card.billing_address.postal_code.should == '56789'
45
+ expect(braintree_credit_card.cardholder_name).to eq('Foo Bar')
46
+ expect(braintree_credit_card.billing_address.postal_code).to eq('56789')
47
47
  end
48
48
 
49
49
  it 'should be able to update just expiration year' do
@@ -52,10 +52,10 @@ describe 'Credit Card Integration' do
52
52
 
53
53
  credit_card.update_attributes!(:cardholder_name => 'Foo Bar', :number => '4111111111111111', :options => {:verify_card => true}, :expiration_month => '07', :expiration_year => '2013', :billing_address => address_hash.merge(:postal_code => '56789'))
54
54
  braintree_credit_card = Braintree::CreditCard.find(credit_card.id)
55
- braintree_credit_card.cardholder_name.should == 'Foo Bar'
56
- braintree_credit_card.billing_address.postal_code.should == '56789'
57
- braintree_credit_card.expiration_month.should == '07'
58
- braintree_credit_card.expiration_year.should == '2013'
55
+ expect(braintree_credit_card.cardholder_name).to eq('Foo Bar')
56
+ expect(braintree_credit_card.billing_address.postal_code).to eq('56789')
57
+ expect(braintree_credit_card.expiration_month).to eq('07')
58
+ expect(braintree_credit_card.expiration_year).to eq('2013')
59
59
  end
60
60
 
61
61
  it 'should be able to update by expiration date' do
@@ -64,11 +64,11 @@ describe 'Credit Card Integration' do
64
64
 
65
65
  credit_card.update_attributes!(:cardholder_name => 'Foo Bar', :number => '4111111111111111', :options => {:verify_card => true}, :expiration_date => '08/2013', :billing_address => address_hash.merge(:postal_code => '56789'))
66
66
  braintree_credit_card = Braintree::CreditCard.find(credit_card.id)
67
- braintree_credit_card.cardholder_name.should == 'Foo Bar'
68
- braintree_credit_card.billing_address.postal_code.should == '56789'
69
- braintree_credit_card.expiration_month.should == '08'
70
- braintree_credit_card.expiration_year.should == '2013'
71
- braintree_credit_card.expiration_date.should == '08/2013'
67
+ expect(braintree_credit_card.cardholder_name).to eq('Foo Bar')
68
+ expect(braintree_credit_card.billing_address.postal_code).to eq('56789')
69
+ expect(braintree_credit_card.expiration_month).to eq('08')
70
+ expect(braintree_credit_card.expiration_year).to eq('2013')
71
+ expect(braintree_credit_card.expiration_date).to eq('08/2013')
72
72
  end
73
73
 
74
74
  it 'should be able to destroy existing credit card' do
@@ -77,8 +77,8 @@ describe 'Credit Card Integration' do
77
77
 
78
78
  credit_card.destroy!
79
79
  expect { Braintree::CreditCard.find(credit_card.token) }.to raise_error(Braintree::NotFoundError)
80
- credit_card.should_not be_persisted
81
- credit_card.should be_frozen
80
+ expect(credit_card).to_not be_persisted
81
+ expect(credit_card).to be_frozen
82
82
  end
83
83
 
84
84
  it 'should be able to capture braintree api errors' do
@@ -8,24 +8,24 @@ describe 'Customer Integration' do
8
8
  it 'should fetch customer from Braintree for given id' do
9
9
  braintree_customer = Braintree::Customer.create!(:first_name => 'Brain', :last_name => 'Tree')
10
10
  customer = BraintreeRails::Customer.new(braintree_customer.id)
11
- customer.id.should == braintree_customer.id
12
- customer.first_name.should == 'Brain'
13
- customer.last_name.should == 'Tree'
14
- customer.should be_persisted
11
+ expect(customer.id).to eq(braintree_customer.id)
12
+ expect(customer.first_name).to eq('Brain')
13
+ expect(customer.last_name).to eq('Tree')
14
+ expect(customer).to be_persisted
15
15
  end
16
16
 
17
17
  it 'should be able to create new customer' do
18
18
  customer = BraintreeRails::Customer.create(:first_name => 'Brain', :last_name => 'Tree')
19
19
  braintree_customer = Braintree::Customer.find(customer.id)
20
20
 
21
- braintree_customer.first_name.should == 'Brain'
22
- braintree_customer.last_name.should == 'Tree'
21
+ expect(braintree_customer.first_name).to eq('Brain')
22
+ expect(braintree_customer.last_name).to eq('Tree')
23
23
  end
24
24
 
25
25
  it 'should be able to create new customer with a credit card' do
26
26
  customer = BraintreeRails::Customer.create(:first_name => 'Brain', :last_name => 'Tree', :credit_card => credit_card_hash)
27
27
  braintree_customer = Braintree::Customer.find(customer.id)
28
- braintree_customer.credit_cards.count.should == 1
28
+ expect(braintree_customer.credit_cards.count).to eq(1)
29
29
  end
30
30
 
31
31
  it 'should be able to update existing customer' do
@@ -33,8 +33,8 @@ describe 'Customer Integration' do
33
33
  customer.update_attributes!(:first_name => 'Foo', :last_name => 'Bar')
34
34
 
35
35
  braintree_customer = Braintree::Customer.find(customer.id)
36
- braintree_customer.first_name.should == 'Foo'
37
- braintree_customer.last_name.should == 'Bar'
36
+ expect(braintree_customer.first_name).to eq('Foo')
37
+ expect(braintree_customer.last_name).to eq('Bar')
38
38
  end
39
39
 
40
40
  it 'should be able to update existing customer with new credit card' do
@@ -42,35 +42,35 @@ describe 'Customer Integration' do
42
42
  customer.update_attributes!(:first_name => 'Foo', :last_name => 'Bar', :credit_card => credit_card_hash.merge(:cardholder_name => "FooBar"))
43
43
 
44
44
  braintree_customer = Braintree::Customer.find(customer.id)
45
- braintree_customer.credit_cards.first.cardholder_name.should == "FooBar"
45
+ expect(braintree_customer.credit_cards.first.cardholder_name).to eq("FooBar")
46
46
  end
47
47
 
48
48
  it 'should be able to destroy existing customer' do
49
49
  customer = BraintreeRails::Customer.create!(:first_name => 'Brain', :last_name => 'Tree')
50
50
  customer.destroy
51
51
  expect { Braintree::Customer.find(customer.id) }.to raise_error(Braintree::NotFoundError)
52
- customer.should_not be_persisted
53
- customer.should be_frozen
52
+ expect(customer).to_not be_persisted
53
+ expect(customer).to be_frozen
54
54
  end
55
55
 
56
56
  it 'should not throw error when trying to destory an already destoryed customer' do
57
57
  customer = BraintreeRails::Customer.create!(:first_name => 'Brain', :last_name => 'Tree')
58
58
  customer.destroy
59
59
  expect { customer.destroy }.not_to raise_error()
60
- customer.should_not be_persisted
61
- customer.should be_frozen
60
+ expect(customer).to_not be_persisted
61
+ expect(customer).to be_frozen
62
62
  end
63
63
 
64
64
  it "should be able to reload the customer attributes" do
65
65
  customer = BraintreeRails::Customer.create!(:first_name => 'Brain', :last_name => 'Tree')
66
66
  customer.first_name = 'new name'
67
- customer.reload.first_name.should == 'Brain'
67
+ expect(customer.reload.first_name).to eq('Brain')
68
68
  end
69
69
 
70
70
  it "should be able to reload associations" do
71
71
  customer = BraintreeRails::Customer.create!(:first_name => 'Brain', :last_name => 'Tree')
72
- customer.credit_cards.should be_empty
72
+ expect(customer.credit_cards).to be_empty
73
73
  Braintree::CreditCard.create(credit_card_hash.merge(:customer_id => customer.id))
74
- customer.reload.credit_cards.size.should == 1
74
+ expect(customer.reload.credit_cards.size).to eq(1)
75
75
  end
76
76
  end
@@ -4,34 +4,34 @@ describe 'MerchantAccount Integration' do
4
4
  it 'should fetch merchant account from Braintree for given id' do
5
5
  braintree_merchant_account = Braintree::MerchantAccount.find(BraintreeRails::Configuration.default_merchant_account_id)
6
6
  merchant_account = BraintreeRails::MerchantAccount.new(BraintreeRails::Configuration.default_merchant_account_id)
7
- merchant_account.id.should == braintree_merchant_account.id
8
- merchant_account.status.should == braintree_merchant_account.status
7
+ expect(merchant_account.id).to eq(braintree_merchant_account.id)
8
+ expect(merchant_account.status).to eq(braintree_merchant_account.status)
9
9
  end
10
10
 
11
11
  it 'can create sub merchant account' do
12
12
  merchant_account = BraintreeRails::MerchantAccount.create(merchant_account_hash)
13
- merchant_account.should be_persisted
13
+ expect(merchant_account).to be_persisted
14
14
  end
15
15
 
16
16
  it 'does not consider merchant account persisted if rejected by Braintree' do
17
17
  merchant_account = BraintreeRails::MerchantAccount.create(merchant_account_hash.merge(:tos_accepted => 'false'))
18
- merchant_account.should_not be_persisted
18
+ expect(merchant_account).to_not be_persisted
19
19
  end
20
20
 
21
21
  it 'sets validation errors properly to its associations' do
22
22
  merchant_account = BraintreeRails::MerchantAccount.create(merchant_account_hash.merge(:individual => {}, :funding => {}, :business => {:legal_name => "foo"}))
23
- merchant_account.should_not be_persisted
24
- merchant_account.individual.errors.should_not be_empty
25
- merchant_account.funding.errors.should_not be_empty
26
- merchant_account.business.errors.should_not be_empty
23
+ expect(merchant_account).to_not be_persisted
24
+ expect(merchant_account.individual.errors).to_not be_empty
25
+ expect(merchant_account.funding.errors).to_not be_empty
26
+ expect(merchant_account.business.errors).to_not be_empty
27
27
  end
28
28
 
29
29
  it 'can update the submerchant account' do
30
30
  individual = merchant_account_hash[:individual].merge(:first_name => "foo")
31
31
  merchant_account = BraintreeRails::MerchantAccount.create(merchant_account_hash.merge(:individual => individual))
32
- merchant_account.should be_persisted
33
- merchant_account.individual.first_name.should == "foo"
32
+ expect(merchant_account).to be_persisted
33
+ expect(merchant_account.individual.first_name).to eq("foo")
34
34
  merchant_account.update_attributes(:individual => {:first_name => "bar"})
35
- merchant_account.individual.first_name.should == "bar"
35
+ expect(merchant_account.individual.first_name).to eq("bar")
36
36
  end
37
37
  end
@@ -6,19 +6,18 @@ describe 'Transaction Integration' do
6
6
  end
7
7
 
8
8
  it 'should be able to create, submit, void transactions for a customer' do
9
-
10
9
  braintree_customer = Braintree::Customer.create!(customer_hash.merge(:credit_card => credit_card_hash))
11
10
  customer = BraintreeRails::Customer.new(braintree_customer)
12
11
 
13
12
  transaction = BraintreeRails::Transaction.create!(:customer => customer, :amount => (1..5).to_a.sample)
14
- transaction.should be_persisted
15
- transaction.status.should == Braintree::Transaction::Status::Authorized
13
+ expect(transaction).to be_persisted
14
+ expect(transaction.status).to eq(Braintree::Transaction::Status::Authorized)
16
15
 
17
16
  transaction.submit_for_settlement!
18
- transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
17
+ expect(transaction.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
19
18
 
20
19
  transaction.void!
21
- transaction.status.should == Braintree::Transaction::Status::Voided
20
+ expect(transaction.status).to eq(Braintree::Transaction::Status::Voided)
22
21
  end
23
22
 
24
23
  it 'should be able to create, submit, void transactions for a customer with a credit_card' do
@@ -27,14 +26,14 @@ describe 'Transaction Integration' do
27
26
  credit_card = customer.credit_cards.first
28
27
 
29
28
  transaction = BraintreeRails::Transaction.create!(:customer => customer, :amount => (1..5).to_a.sample, :credit_card => credit_card)
30
- transaction.should be_persisted
31
- transaction.status.should == Braintree::Transaction::Status::Authorized
29
+ expect(transaction).to be_persisted
30
+ expect(transaction.status).to eq(Braintree::Transaction::Status::Authorized)
32
31
 
33
32
  transaction.submit_for_settlement!
34
- transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
33
+ expect(transaction.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
35
34
 
36
35
  transaction.void!
37
- transaction.status.should == Braintree::Transaction::Status::Voided
36
+ expect(transaction.status).to eq(Braintree::Transaction::Status::Voided)
38
37
  end
39
38
 
40
39
 
@@ -44,11 +43,11 @@ describe 'Transaction Integration' do
44
43
  credit_card = customer.credit_cards.first
45
44
  transaction = BraintreeRails::Transaction.create!(:amount => (1..10).to_a.sample, :customer => customer)
46
45
 
47
- customer.transactions.length.should == 1
46
+ expect(customer.transactions.length).to eq(1)
48
47
  customer.transactions.each do |t|
49
- t.should == transaction
48
+ expect(t).to eq(transaction)
50
49
  end
51
- credit_card.transactions.count.should == 1
50
+ expect(credit_card.transactions.count).to eq(1)
52
51
  end
53
52
 
54
53
  it "should be able to load all transactions for a given customer" do
@@ -56,19 +55,19 @@ describe 'Transaction Integration' do
56
55
  customer = BraintreeRails::Customer.new(braintree_customer)
57
56
  credit_card1 = customer.credit_cards.create!(credit_card_hash.merge(:token => nil))
58
57
  credit_card2 = customer.credit_cards.create!(credit_card_hash.merge(:token => nil))
59
- customer.credit_cards.size.should == 2
58
+ expect(customer.credit_cards.size).to eq(2)
60
59
 
61
60
  transaction1 = BraintreeRails::Transaction.create!(:amount => (1..10).to_a.sample, :customer => customer, :credit_card => credit_card1)
62
61
  transaction2 = BraintreeRails::Transaction.create!(:amount => (1..10).to_a.sample, :customer => customer, :credit_card => credit_card2)
63
- customer.transactions.size.should == 2
62
+ expect(customer.transactions.size).to eq(2)
64
63
  end
65
64
 
66
65
  it 'should be able to create a one time transaction' do
67
66
  transaction = BraintreeRails::Transaction.create!(:amount => (1..10).to_a.sample, :billing => address_hash, :customer => customer_hash, :credit_card => credit_card_hash)
68
- transaction.should be_persisted
69
- transaction.id.should_not be_blank
70
- transaction.customer.should_not be_blank
71
- transaction.credit_card.should_not be_blank
67
+ expect(transaction).to be_persisted
68
+ expect(transaction.id).to_not be_blank
69
+ expect(transaction.customer).to_not be_blank
70
+ expect(transaction.credit_card).to_not be_blank
72
71
  end
73
72
 
74
73
  it 'should be able to capture braintree api errors' do
@@ -78,8 +77,8 @@ describe 'Transaction Integration' do
78
77
  transaction = BraintreeRails::Transaction.create!(:amount => (1..10).to_a.sample, :customer => customer)
79
78
 
80
79
  transaction.void!
81
- transaction.submit_for_settlement.should be_false
82
- transaction.errors[:status].should_not be_blank
80
+ expect(transaction.submit_for_settlement).to eq(false)
81
+ expect(transaction.errors[:status]).to_not be_blank
83
82
  end
84
83
 
85
84
  describe BraintreeRails::Transactions do
@@ -90,8 +89,8 @@ describe 'Transaction Integration' do
90
89
  credit_card = customer.default_credit_card
91
90
 
92
91
  transaction = BraintreeRails::Transactions.new(customer).create!(:amount => (1..10).to_a.sample)
93
- transaction.customer.should == customer
94
- transaction.credit_card.should == credit_card
92
+ expect(transaction.customer).to eq(customer)
93
+ expect(transaction.credit_card).to eq(credit_card)
95
94
  end
96
95
 
97
96
  it 'can use default credit_card to build new record' do
@@ -100,7 +99,7 @@ describe 'Transaction Integration' do
100
99
  credit_card = customer.default_credit_card
101
100
 
102
101
  transaction = BraintreeRails::Transactions.new(credit_card).create!(:amount => (1..10).to_a.sample)
103
- transaction.credit_card.should == credit_card
102
+ expect(transaction.credit_card).to eq(credit_card)
104
103
  end
105
104
  end
106
105
 
@@ -109,10 +108,10 @@ describe 'Transaction Integration' do
109
108
  customer = BraintreeRails::Customer.create!(customer_hash.merge(:credit_card => credit_card_hash))
110
109
  credit_card = customer.credit_cards.create!(credit_card_hash.merge(:token => 'card_1'))
111
110
  transactions = customer.transactions
112
- transactions.should be_empty
111
+ expect(transactions).to be_empty
113
112
 
114
113
  transaction = BraintreeRails::Transaction.create!(:amount => (1..10).to_a.sample, :customer => customer, :credit_card => credit_card)
115
- transactions.reload.size.should == 1
114
+ expect(transactions.reload.size).to eq(1)
116
115
  end
117
116
  end
118
117
  end
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
2
+ require 'yaml'
2
3
  SimpleCov.command_name "spec:integration"
3
4
 
4
5
  config = File.join(SPEC_PATH, 'config/braintree_auth.yml')
@@ -9,7 +10,7 @@ if File.exist?(config) && auth = YAML.load_file(config)
9
10
  BraintreeRails::Configuration.private_key = auth['private_key']
10
11
  BraintreeRails::Configuration.default_merchant_account_id = auth['default_merchant_account_id']
11
12
  # BraintreeRails::Configuration.logger = Logger.new('log/braintree.log')
12
- elsif ENV["TRAVIS_SECURE_ENV_VARS"] == "true" && ENV["TRAVIS_RUBY_VERSION"] == "2.0.0"
13
+ elsif ENV["TRAVIS_SECURE_ENV_VARS"] == "true" && ENV["TRAVIS_RUBY_VERSION"] == "2.1.2"
13
14
  BraintreeRails::Configuration.environment = :sandbox
14
15
  BraintreeRails::Configuration.merchant_id = ENV['merchant_id']
15
16
  BraintreeRails::Configuration.public_key = ENV['public_key']
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '../lib/test_env'))
2
+ I18n.enforce_available_locales = false
2
3
 
3
4
  SPEC_PATH = File.expand_path(File.dirname(__FILE__))
4
5
  FIXTURE_PATH = File.join(SPEC_PATH, 'fixtures')
@@ -4,8 +4,22 @@ module Helper
4
4
  end
5
5
 
6
6
  def stub_braintree_request(method, path, response)
7
- response = response.reverse_merge(:headers => {'Content-Type' => ['application/xml', 'charset=utf-8'], 'Content-Encoding' => 'gzip'})
8
- stub_request(method, BraintreeBaseUri+path).to_return(response)
7
+ configuration = Braintree::Configuration.instantiate
8
+ request_header = {
9
+ :headers => {
10
+ 'Accept'=>'application/xml',
11
+ 'Accept-Encoding'=>'gzip',
12
+ 'User-Agent'=> configuration.user_agent,
13
+ 'X-Apiversion'=> configuration.api_version
14
+ }
15
+ }
16
+ response_header = {
17
+ :headers => {
18
+ 'Content-Type' => ['application/xml', 'charset=utf-8'],
19
+ 'Content-Encoding' => 'gzip'
20
+ }
21
+ }
22
+ stub_request(method, BraintreeBaseUri+path).with(request_header).to_return(response.reverse_merge(response_header))
9
23
  end
10
24
 
11
25
  def address_hash
@@ -10,10 +10,10 @@ describe BraintreeRails::AddOn do
10
10
  braintree_add_on = Braintree::AddOn.all.find { |a| a.id == 'add_on_id' }
11
11
  add_on = BraintreeRails::AddOn.new(braintree_add_on)
12
12
 
13
- add_on.should be_persisted
14
- add_on.never_expires?.should == braintree_add_on.never_expires?
13
+ expect(add_on).to be_persisted
14
+ expect(add_on.never_expires?).to eq(braintree_add_on.never_expires?)
15
15
  BraintreeRails::AddOn.attributes.each do |attribute|
16
- add_on.send(attribute).should == braintree_add_on.send(attribute)
16
+ expect(add_on.send(attribute)).to eq(braintree_add_on.send(attribute))
17
17
  end
18
18
  end
19
19
 
@@ -21,9 +21,9 @@ describe BraintreeRails::AddOn do
21
21
  braintree_add_on = Braintree::AddOn.all.find { |a| a.id == 'add_on_id' }
22
22
  add_on = BraintreeRails::AddOn.new('add_on_id')
23
23
 
24
- add_on.should be_persisted
24
+ expect(add_on).to be_persisted
25
25
  BraintreeRails::AddOn.attributes.each do |attribute|
26
- add_on.send(attribute).should == braintree_add_on.send(attribute)
26
+ expect(add_on.send(attribute)).to eq(braintree_add_on.send(attribute))
27
27
  end
28
28
  end
29
29
 
@@ -31,9 +31,9 @@ describe BraintreeRails::AddOn do
31
31
  braintree_add_on = Braintree::AddOn.all.find { |a| a.id == 'add_on_id' }
32
32
  add_on = BraintreeRails::AddOn.find('add_on_id')
33
33
 
34
- add_on.should be_persisted
34
+ expect(add_on).to be_persisted
35
35
  BraintreeRails::AddOn.attributes.each do |attribute|
36
- add_on.send(attribute).should == braintree_add_on.send(attribute)
36
+ expect(add_on.send(attribute)).to eq(braintree_add_on.send(attribute))
37
37
  end
38
38
  end
39
39
  end
@@ -43,9 +43,8 @@ describe BraintreeRails::AddOn do
43
43
  braintree_add_ons = Braintree::AddOn.all
44
44
  add_ons = BraintreeRails::AddOn.all
45
45
 
46
- add_ons.should respond_to(:each)
47
- add_ons.size.should == braintree_add_ons.size
46
+ expect(add_ons).to respond_to(:each)
47
+ expect(add_ons.size).to eq(braintree_add_ons.size)
48
48
  end
49
49
  end
50
- end
51
-
50
+ end