Permalink
Browse files

use _thing_name() when checking attribute options

  • Loading branch information...
1 parent d380582 commit 1e3c3fa41091b6e226d0f2592d728416e9a84280 @RsrchBoy committed Oct 2, 2012
Showing with 10 additions and 8 deletions.
  1. +10 −8 lib/Test/Moose/More.pm
@@ -382,7 +382,7 @@ sub _validate_attribute {
map { $_ => delete $opts{"-$_"} }
map { s/^-//; $_ }
grep { /^-/ }
- keys %opts
+ sort keys %opts
;
validate_thing $att => %thing_opts
@@ -412,6 +412,8 @@ sub _attribute_options_ok {
local $Test::Builder::Level = $Test::Builder::Level + 1;
my $name = $att->name;
+ my $thing_name = _thing_name($name, $att);
+
# XXX do we really want to do this?
if (my $is = delete $opts{is}) {
$opts{accessor} = $name if $is eq 'rw' && ! exists $opts{accessor};
@@ -424,13 +426,13 @@ sub _attribute_options_ok {
my $has = "has_$property";
defined $value
- ? ok($att->$has, "attribute $name has a $property")
- : ok(!$att->$has, "attribute $name does not have a $property")
+ ? ok($att->$has, "$thing_name has a $property")
+ : ok(!$att->$has, "$thing_name does not have a $property")
;
- is($att->$property, $value, "$name: $property correct")
+ is($att->$property, $value, "$thing_name option $property correct")
};
- $check->($_) for grep { any(@check_opts) eq $_ } keys %opts;
+ $check->($_) for grep { any(@check_opts) eq $_ } sort keys %opts;
do { $tb->skip("cannot test '$_' options yet", 1); delete $opts{$_} }
for grep { exists $opts{$_} } @unhandled_opts;
@@ -439,16 +441,16 @@ sub _attribute_options_ok {
$opts{init_arg}
? $check->('init_arg')
- : ok(!$att->has_init_arg, "$name has no init_arg")
+ : ok(!$att->has_init_arg, "$thing_name has no init_arg")
;
delete $opts{init_arg};
}
if (exists $opts{lazy}) {
delete $opts{lazy}
- ? ok($att->is_lazy, "attribute $name is lazy")
- : ok(!$att->is_lazy, "attribute $name is not lazy")
+ ? ok($att->is_lazy, "$thing_name is lazy")
+ : ok(!$att->is_lazy, "$thing_name is not lazy")
;
}

0 comments on commit 1e3c3fa

Please sign in to comment.