Skip to content

Commit

Permalink
attributes: allow to check an attribute is *not* required, as well
Browse files Browse the repository at this point in the history
  • Loading branch information
rsrchboy committed Oct 8, 2016
1 parent 56d122b commit efd93b1
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/Test/Moose/More.pm
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,11 @@ sub _role_attribute_options_ok {
my $name = $att->name;
my $thing_name = _thing_name($name, $att);

# this much works, at least
exists $opts{required} and delete $opts{required}
? ok($att->is_required, "$thing_name is required")
: ok(!$att->is_required, "$thing_name is not required")
;

exists $opts{coerce} and delete $opts{coerce}
? ok( $att->should_coerce, "$thing_name should coerce")
: ok(!$att->should_coerce, "$thing_name should not coerce")
Expand Down Expand Up @@ -913,13 +917,10 @@ sub _class_attribute_options_ok {
is($att->$property, $value, "$thing_name option $property correct")
};

if (my $is_required = delete $opts{required}) {

$is_required
? ok($att->is_required, "$thing_name is required")
: ok(!$att->is_required, "$thing_name is not required")
;
}
exists $opts{required} and delete $opts{required}
? ok($att->is_required, "$thing_name is required")
: ok(!$att->is_required, "$thing_name is not required")
;

$check->($_) for grep { any(@check_opts) eq $_ } sort keys %opts;

Expand Down

0 comments on commit efd93b1

Please sign in to comment.