Credit Cards #40

Merged
merged 4 commits into from Sep 8, 2011

Conversation

Projects
None yet
3 participants
@toddmazierski
Contributor

toddmazierski commented Sep 7, 2011

Added random credit card type and number generation, with tests.

Number generation and check digit calculation are based upon the work of Graham King: http://www.darkcoding.net/credit-card-generator/

Test helper functions are based upon the work of @tinogomes: https://gist.github.com/1182499

@nate

This comment has been minimized.

Show comment
Hide comment
@nate

nate Sep 8, 2011

Collaborator

I dig this, but Array#choice is ruby 1.8.7 only. We have internal utilities for getting random elements of an array. I'll fix this and merge it in, thanks for the contrib!

Collaborator

nate commented Sep 8, 2011

I dig this, but Array#choice is ruby 1.8.7 only. We have internal utilities for getting random elements of an array. I'll fix this and merge it in, thanks for the contrib!

@nate nate merged commit b2b5ff4 into sevenwire:master Sep 8, 2011

@toddmazierski

This comment has been minimized.

Show comment
Hide comment
@toddmazierski

toddmazierski Sep 8, 2011

Contributor

I was not aware that choice was depreciated. Thanks for the tip, and correcting my mistake, @nate!

Contributor

toddmazierski commented Sep 8, 2011

I was not aware that choice was depreciated. Thanks for the tip, and correcting my mistake, @nate!

@tinogomes

This comment has been minimized.

Show comment
Hide comment
@tinogomes

tinogomes Sep 8, 2011

@toddmazierski

I saw you removed the association validation on valid_credit_card method, so you can pass a "valid credit card number", but without correct association. I understand you are using into a controlled environment (test), but if anyone copy this code from your test suite, can get invalid result ;)

Cheers

@toddmazierski

I saw you removed the association validation on valid_credit_card method, so you can pass a "valid credit card number", but without correct association. I understand you are using into a controlled environment (test), but if anyone copy this code from your test suite, can get invalid result ;)

Cheers

@toddmazierski

This comment has been minimized.

Show comment
Hide comment
@toddmazierski

toddmazierski Sep 8, 2011

Contributor

@tinogomes

That was precisely my line of reasoning. The trade-off appeared to be between more complete test coverage and more informative failures, and I chose more informative failures. I tried to work around the reduced coverage by having more, and a good mix of valid_number?and which_type? -based tests, with the added benefit of having each one illustrating how a different option worked. In my estimation, the chances of all of them passing with invalid data, in the same pass, is very low.

That said, if anyone feels strongly about it, I'm certainly open to modifying the tests!

Contributor

toddmazierski commented Sep 8, 2011

@tinogomes

That was precisely my line of reasoning. The trade-off appeared to be between more complete test coverage and more informative failures, and I chose more informative failures. I tried to work around the reduced coverage by having more, and a good mix of valid_number?and which_type? -based tests, with the added benefit of having each one illustrating how a different option worked. In my estimation, the chances of all of them passing with invalid data, in the same pass, is very low.

That said, if anyone feels strongly about it, I'm certainly open to modifying the tests!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment