Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Test that billing address is recorded.

  • Loading branch information...
commit 26cbdd328205410bcd3bbe8dad0a49da062910c0 1 parent 5690d40
@gabebw gabebw authored
Showing with 62 additions and 44 deletions.
  1. +62 −44 spec/fake_braintree/customer_spec.rb
View
106 spec/fake_braintree/customer_spec.rb
@@ -1,55 +1,73 @@
require 'spec_helper'
-describe FakeBraintree::SinatraApp do
- context "Braintree::Customer.create" do
- let(:cc_number) { %w(4111 1111 1111 1111).join }
- let(:expiration_date) { "04/2016" }
- after { FakeBraintree.verify_all_cards = false }
-
- def create_customer_with_credit_card(options)
- Braintree::Customer.create(:credit_card => options)
+describe FakeBraintree::SinatraApp, "Braintree::Customer.create" do
+ let(:cc_number) { %w(4111 1111 1111 1111).join }
+ let(:expiration_date) { "04/2016" }
+ after { FakeBraintree.verify_all_cards = false }
+
+ def create_customer_with_credit_card(options)
+ Braintree::Customer.create(:credit_card => options)
+ end
+
+ it "successfully creates a customer" do
+ result = create_customer_with_credit_card(:number => cc_number,
+ :expiration_date => expiration_date)
+ result.should be_success
+ end
+
+ it "records the billing address" do
+ result = create_customer_with_credit_card(
+ :number => cc_number,
+ :expiration_date => expiration_date,
+ :billing_address => {
+ :street_address => "1 E Main St",
+ :extended_address => "Suite 3",
+ :locality => "Chicago",
+ :region => "Illinois",
+ :postal_code => "60622",
+ :country_code_alpha2 => "US"
+ }
+ )
+
+ billing_address = result.customer.credit_cards[0].billing_address
+
+ billing_address.street_address.should == "1 E Main St"
+ billing_address.postal_code.should == "60622"
+ end
+
+ context "when passed :verify_card => true" do
+ it "accepts valid cards" do
+ create_customer_with_credit_card(
+ :number => cc_number,
+ :expiration_date => expiration_date,
+ :options => { :verify_card => true }
+ ).should be_success
end
- it "successfully creates a customer" do
- result = create_customer_with_credit_card(:number => cc_number,
- :expiration_date => expiration_date)
- result.should be_success
+ it "rejects invalid cards" do
+ create_customer_with_credit_card(
+ :number => '123456',
+ :expiration_date => expiration_date,
+ :options => { :verify_card => true }
+ ).should_not be_success
end
+ end
+
+ context "when FakeBraintree.verify_all_cards == true" do
+ before { FakeBraintree.verify_all_cards! }
- context "when passed :verify_card => true" do
- it "accepts valid cards" do
- create_customer_with_credit_card(
- :number => cc_number,
- :expiration_date => expiration_date,
- :options => { :verify_card => true }
- ).should be_success
- end
-
- it "rejects invalid cards" do
- create_customer_with_credit_card(
- :number => '123456',
- :expiration_date => expiration_date,
- :options => { :verify_card => true }
- ).should_not be_success
- end
+ it "accepts valid cards" do
+ create_customer_with_credit_card(
+ :number => cc_number,
+ :expiration_date => expiration_date
+ ).should be_success
end
- context "when FakeBraintree.verify_all_cards == true" do
- before { FakeBraintree.verify_all_cards! }
-
- it "accepts valid cards" do
- create_customer_with_credit_card(
- :number => cc_number,
- :expiration_date => expiration_date
- ).should be_success
- end
-
- it "rejects invalid cards" do
- create_customer_with_credit_card(
- :number => '123456',
- :expiration_date => expiration_date
- ).should_not be_success
- end
+ it "rejects invalid cards" do
+ create_customer_with_credit_card(
+ :number => '123456',
+ :expiration_date => expiration_date
+ ).should_not be_success
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.