Skip to content
Permalink
Browse files
Automatically calculate a future date for credit cards.
Let's not have this test fail in a few years.
  • Loading branch information
steveklabnik committed May 2, 2014
1 parent d966c24 commit 7febadb38c3a4258c72ab82c44218f8e5859d65f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
@@ -18,11 +18,13 @@
end

When(/^I try to tokenize the card "(.*?)" with the CVV "(.*?)"$/) do |number, cvv|
require 'date'

@client.post('/cards',
{
number: number,
expiration_month: 12,
expiration_year: 2016,
expiration_month: (Date.today.month + 1) % 12,

This comment has been minimized.

Copy link
@jtdowney

jtdowney May 2, 2014

In November wouldn't this make the month 0? (11 + 1) % 12 == 0

I think you actually want either (Date.today.month % 12) + 1 or to just leave it static since you're already pushing the year into the future.

This comment has been minimized.

Copy link
@steveklabnik

steveklabnik May 2, 2014

Author Contributor

Ahh, good call. Yeah, keeping it the same month is probably simplest.

expiration_year: Date.today.year + 1,
cvv: cvv,
address: {
line1: "965 Mission St",
@@ -6,6 +6,8 @@ Feature: Test information
We also provide test data for underwriting, identity verification, and AVS
information.

Note: all credit cards must include a future expiration date and month. This
is calculated automatically inside the test.

Scenario: Successful VISA charge.
The 4111111111111111 code gives you a VISA card that can be charged.

0 comments on commit 7febadb

Please sign in to comment.