Skip to content

unit tests should exercise all combinations of Net::Stripe object argument types #139

Open
@sherrardb

Description

@sherrardb

this is a general note, and a very-long-term todo list item.

basically, what i have discovered while working on #94, #134, #137, #138, etc, is that there are various combinations of argument types that we are not testing for, based on the values we claim to accept in the Kavorka signature for a given method.

for example, take post_customer(). it accepts Net::Stripe::Customer|Str for customer and it accepts Net::Stripe::Card|Net::Stripe::Token|Str|HashRef for card with Str representing either token id or card id. that leaves us with 2 x 5 combinations that we should be testing.

then, add to that the fact that post_customer() can be called to create a customer or update an existing customer, and we have 2 x 2 x 5 combinations.

while this might seem like overkill, the reality is that any of these individual combinations is subject to fail either because of how the method is written or because of the restrictions of the Stripe API. for example, the API call for post_charge() works when passing a token id with no customer, but fails when passing token id with an existing customer.

so my current approach, which is subject to change :-), is to add appropriate unit tests for the stated Net::Stripe object arguments, and to either add more-nuanced validation to provide a predictable, pre-API-call error for the combinations that we know not to work, or to remove the TypeConstraint from the Kavorka signature if an argument type fails in all combinations.

side note: the parameter validation seems to be made a little bit cleaner by having separate methods for creation and updating in cases where the acceptable argument types differ between the two calling forms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions