Permalink
Browse files

Separate the phases of the 4-phase test

  • Loading branch information...
1 parent 5235a0f commit 243acdcb9564ad5bf0134e7da7bb753869b18204 @gabebw gabebw committed May 25, 2014
Showing with 13 additions and 6 deletions.
  1. +1 −1 Rakefile
  2. +8 −3 spec/fake_braintree/address_spec.rb
  3. +4 −2 spec/fake_braintree/credit_card_spec.rb
View
@@ -5,4 +5,4 @@ require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
desc 'Run specs'
-task :default => [:spec]
+task default: [:spec]
@@ -2,8 +2,13 @@
describe "Braintree::Address.create" do
it "successfully creates address with valid data" do
- result = create_customer
- result = Braintree::Address.create(customer_id: result.customer.id, postal_code: 30339)
- expect(result).to be_success
+ customer_response = create_customer
+
+ address_response = Braintree::Address.create(
+ customer_id: customer_response.customer.id,
+ postal_code: 30339
+ )
+
+ expect(address_response).to be_success
end
end
@@ -22,6 +22,7 @@ def token_for(month, year)
describe 'Braintree::CreditCard.sale' do
it 'successfully creates a sale' do
result = Braintree::CreditCard.sale(cc_token, amount: 10.00)
+
expect(result).to be_success
expect(Braintree::Transaction.find(result.transaction.id)).to be
end
@@ -31,6 +32,7 @@ def token_for(month, year)
describe 'Braintree::CreditCard.create' do
it 'allows creating a credit card without a customer' do
result = Braintree::CreditCard.create(build_credit_card_hash)
+
expect(result).to be_success
expect(Braintree::CreditCard.find('token')).to_not be_nil
end
@@ -42,18 +44,18 @@ def token_for(month, year)
it 'fails to create a credit card if decline_all_cards is set' do
FakeBraintree.decline_all_cards!
+
result = Braintree::CreditCard.create(build_credit_card_hash)
+
expect(result).to_not be_success
expect { Braintree::CreditCard.find('token') }.to raise_error Braintree::NotFoundError
- FakeBraintree.clear!
end
it 'fails to create a credit card if verify_all_cards is set and card is invalid' do
FakeBraintree.verify_all_cards!
result = Braintree::CreditCard.create(build_credit_card_hash.merge(number: '12345'))
expect(result).to_not be_success
expect { Braintree::CreditCard.find('token') }.to raise_error Braintree::NotFoundError
- FakeBraintree.verify_all_cards = false
end
it 'successfully creates a credit card' do

0 comments on commit 243acdc

Please sign in to comment.