Permalink
Browse files

Clean up specs.

  • Loading branch information...
1 parent 0f6ed3f commit 5690d4025039c137cf3e9187c99da2115f92832b Gabe Berke-Williams committed Nov 3, 2011
Showing with 25 additions and 21 deletions.
  1. +25 −21 spec/fake_braintree/customer_spec.rb
@@ -6,46 +6,50 @@
let(:expiration_date) { "04/2016" }
after { FakeBraintree.verify_all_cards = false }
- it "successfully creates a customer" do
- result = Braintree::Customer.create(
- :credit_card => {
- :number => cc_number,
- :expiration_date => expiration_date
- })
+ 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 "verifies the card number when passed :verify_card => true" do
- Braintree::Customer.create(
- :credit_card => {
+ 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
+ ).should be_success
+ end
- Braintree::Customer.create(
- :credit_card => {
+ it "rejects invalid cards" do
+ create_customer_with_credit_card(
:number => '123456',
:expiration_date => expiration_date,
:options => { :verify_card => true }
- }).should_not be_success
+ ).should_not be_success
+ end
end
- it "verifies the card number when FakeBraintree.verify_all_cards == true" do
- FakeBraintree.verify_all_cards!
+ context "when FakeBraintree.verify_all_cards == true" do
+ before { FakeBraintree.verify_all_cards! }
- Braintree::Customer.create(
- :credit_card => {
+ it "accepts valid cards" do
+ create_customer_with_credit_card(
:number => cc_number,
:expiration_date => expiration_date
- }).should be_success
+ ).should be_success
+ end
- Braintree::Customer.create(
- :credit_card => {
+ it "rejects invalid cards" do
+ create_customer_with_credit_card(
:number => '123456',
:expiration_date => expiration_date
- }).should_not be_success
+ ).should_not be_success
+ end
end
end
end

0 comments on commit 5690d40

Please sign in to comment.