Skip to content

Commit

Permalink
Clean up specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Berke-Williams committed Nov 3, 2011
1 parent 0f6ed3f commit 5690d40
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions spec/fake_braintree/customer_spec.rb
Expand Up @@ -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.