stripe-perl
stripe-perl copied to clipboard
add static tests for coercion functions?
similar to the test currently local.t
my $false = bless( do{\(my $o = 0)}, 'JSON::PP::Boolean' );
my $DATA = {
'client_ip' => '138.197.111.110',
'object' => 'token',
'type' => 'card',
...
'customer' => undef,
'address_line1_check' => undef,
'address_country' => undef
}
};
Unexpected_keys_ignored: {
my $obj = Net::Stripe::_hash_to_object({
%$DATA,
'dummy_object' => {
object => 'foo_bar',
garbage => 'bin',
},
dummy_scalar => 'rubbish',
});
is (ref($obj), 'Net::Stripe::Token', 'unmodelled data has no effect');
ok (! exists($obj->{dummy_object}), 'dummy_object ignored');
ok (! exists($obj->{dummy_scalar}), 'dummy_scalar ignored');
}
we may want to add tests that confirm the expected behavior of _pre_2011_08_01_processing(),
_pre_2012_10_26_processing(), etc.
my testing has always involved forcing the API version with
$req->header( 'Stripe-Version' => $ENV{STRIPE_API_VERSION} ) if exists( $ENV{STRIPE_API_VERSION} );
and iterating over a range of versions using a bash for loop, but obviously this method is of no benefit for users, cpantesters, etc.
methods used on the request side fall into this category as well. and we already have an example:
Placeholder: {
my $return = { Net::Stripe::Resource::form_fields_for_hashref( "hashref", { level1=> { level2=> "value" } } ) };
is_deeply $return, { 'hashref[level1][level2]' => 'value' };
}
that section just needs a name change to remove the implication of transience.