Permalink
Browse files

Use the same CC number most places.

  • Loading branch information...
Gabe Berke-Williams
Gabe Berke-Williams committed Nov 9, 2011
1 parent a5943a7 commit 70af61e0c41b45271e545b09777889b93ea584c8
@@ -2,24 +2,22 @@
describe FakeBraintree::SinatraApp do
context "Braintree::CreditCard.find" do
- let(:cc_number) { %w(4111 1111 1111 9876).join }
- let(:expiration_date) { "04/2016" }
- let(:token) { braintree_credit_card_token(cc_number, expiration_date) }
+ let(:expiration_date) { "04/2016" }
+ let(:token) { braintree_credit_card_token(TEST_CC_NUMBER, expiration_date) }
it "gets the correct credit card" do
credit_card = Braintree::CreditCard.find(token)
- credit_card.last_4.should == "9876"
+ credit_card.last_4.should == TEST_CC_NUMBER[-4,4]
credit_card.expiration_year.should == "2016"
credit_card.expiration_month.should == "04"
end
end
context "Braintree::CreditCard.sale" do
- let(:cc_number) { %w(4111 1111 1111 9876).join }
- let(:expiration_date) { "04/2016" }
- let(:token) { braintree_credit_card_token(cc_number, expiration_date) }
- let(:amount) { 10.00 }
+ let(:expiration_date) { "04/2016" }
+ let(:token) { braintree_credit_card_token(TEST_CC_NUMBER, expiration_date) }
+ let(:amount) { 10.00 }
it "successfully creates a sale" do
result = Braintree::CreditCard.sale(token, amount: amount, options: {submit_for_settlement: true})
@@ -1,7 +1,6 @@
require 'spec_helper'
describe "Braintree::Customer.create" do
- let(:cc_number) { %w(4111 1111 1111 1111).join }
let(:expiration_date) { "04/2016" }
after { FakeBraintree.verify_all_cards = false }
@@ -10,14 +9,14 @@ def create_customer_with_credit_card(options)
end
it "successfully creates a customer" do
- result = create_customer_with_credit_card(:number => cc_number,
+ result = create_customer_with_credit_card(:number => TEST_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,
+ :number => TEST_CC_NUMBER,
:expiration_date => expiration_date,
:billing_address => {
:street_address => "1 E Main St",
@@ -38,7 +37,7 @@ def create_customer_with_credit_card(options)
context "when passed :verify_card => true" do
it "accepts valid cards" do
create_customer_with_credit_card(
- :number => cc_number,
+ :number => TEST_CC_NUMBER,
:expiration_date => expiration_date,
:options => { :verify_card => true }
).should be_success
@@ -58,7 +57,7 @@ def create_customer_with_credit_card(options)
it "accepts valid cards" do
create_customer_with_credit_card(
- :number => cc_number,
+ :number => TEST_CC_NUMBER,
:expiration_date => expiration_date
).should be_success
end
@@ -73,7 +72,6 @@ def create_customer_with_credit_card(options)
end
describe "Braintree::Customer.find" do
- let(:cc_number) { %w(4111 1111 1111 1111).join }
let(:expiration_date) { "04/2016" }
def create_customer(options)
@@ -1,16 +1,15 @@
require 'spec_helper'
describe FakeBraintree, ".credit_card_from_token" do
- let(:cc_number) { %w(4111 1111 1111 9876).join }
let(:cc_number_2) { %w(4111 1111 1111 2222).join }
let(:expiration_date) { "04/2016" }
let(:expiration_date_2) { "05/2019" }
- let(:token) { braintree_credit_card_token(cc_number, expiration_date) }
+ let(:token) { braintree_credit_card_token(TEST_CC_NUMBER, expiration_date) }
let(:token_2) { braintree_credit_card_token(cc_number_2, expiration_date_2) }
it "looks up the credit card based on a CC token" do
credit_card = FakeBraintree.credit_card_from_token(token)
- credit_card["last_4"].should == "9876"
+ credit_card["last_4"].should == TEST_CC_NUMBER[-4,4]
credit_card["expiration_year"].should == "2016"
credit_card["expiration_month"].should == "04"
@@ -22,9 +21,8 @@
end
describe FakeBraintree, ".decline_all_cards!" do
- let(:cc_number) { %w(4111 1111 1111 9876).join }
let(:expiration_date) { "04/2016" }
- let(:token) { braintree_credit_card_token(cc_number, expiration_date) }
+ let(:token) { braintree_credit_card_token(TEST_CC_NUMBER, expiration_date) }
let(:amount) { 10.00 }
before do
View
@@ -8,6 +8,8 @@
Dir.mkdir('tmp') unless Dir.exist?('tmp')
File.new('tmp/braintree_log', 'w').close
+TEST_CC_NUMBER = %w(4111 1111 1111 1111).join
+
RSpec.configure do |config|
config.mock_with :mocha

0 comments on commit 70af61e

Please sign in to comment.