Skip to content

Instantly share code, notes, and snippets.

@j1n3l0
Created October 31, 2019 15:11
Show Gist options
  • Save j1n3l0/69014d59ecaeba15a077775795f6a280 to your computer and use it in GitHub Desktop.
Save j1n3l0/69014d59ecaeba15a077775795f6a280 to your computer and use it in GitHub Desktop.
use Test::Most;
package Class {
use Moo;
use Types::Standard qw< :all >;
has attribute => (
coerce => 1,
is => 'ro',
isa => ArrayRef->parameterize(Str)->plus_coercions(Str, sub {[$_]}),
);
};
cmp_methods(
new_ok( Class => [ attribute => 'hello' ] ),
[ attribute => ['hello'] ],
'should coerce attribute from Str to ArrayRef[Str]',
);
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment