Provided by: libtest-moose-more-perl_0.037-1_all bug

NAME

       Test::Moose::More - More tools for testing Moose packages

VERSION

       This document describes version 0.037 of Test::Moose::More - released January 31, 2016 as
       part of Test-Moose-More.

SYNOPSIS

           use Test::Moose::More;

           is_class_ok 'Some::Class';
           is_role_ok  'Some::Role';
           has_method_ok 'Some::Class', 'foo';

           # ... etc

DESCRIPTION

       This package contains a number of additional tests that can be employed against Moose
       classes/roles.  It is intended to replace Test::Moose in your tests, and re-exports any
       tests that it has and we do not, yet.

FUNCTIONS

   known_sugar
       Returns a list of all the known standard Moose sugar (has, extends, etc).

TEST FUNCTIONS

   meta_ok $thing
       Tests $thing to see if it has a metaclass; $thing may be the class name or instance of the
       class you wish to check.

   does_ok $thing, < $role | \@roles >, [ $message ]
       Checks to see if $thing does the given roles.  $thing may be the class name or instance of
       the class you wish to check.

       Note that the message will be taken verbatim unless it contains %s somewhere; this will be
       replaced with the name of the role being tested for.

   does_not_ok $thing, < $role | \@roles >, [ $message ]
       Checks to see if $thing does not do the given roles.  $thing may be the class name or
       instance of the class you wish to check.

       Note that the message will be taken verbatim unless it contains %s somewhere; this will be
       replaced with the name of the role being tested for.

   has_attribute_ok $thing, $attribute_name, [ $message ]
       Checks $thing for an attribute named $attribute_name; $thing may be a class name,
       instance, or role name.

   has_method_ok $thing, @methods
       Queries $thing's metaclass to see if $thing has the methods named in @methods.

   role_wraps_around_method_ok $role, @methods
       Queries $role's metaclass to see if $role wraps the methods named in @methods with an
       around method modifier.

   role_wraps_before_method_ok $role, @methods
       Queries $role's metaclass to see if $role wraps the methods named in @methods with an
       before method modifier.

   role_wraps_after_method_ok $role, @methods
       Queries $role's metaclass to see if $role wraps the methods named in @methods with an
       after method modifier.

   requires_method_ok $thing, @methods
       Queries $thing's metaclass to see if $thing requires the methods named in @methods.

       Note that this really only makes sense if $thing is a role.

   is_immutable_ok $thing
       Passes if $thing is immutable.

   is_not_immutable_ok $thing
       Passes if $thing is not immutable; that is, is mutable.

   is_role_ok $thing
       Passes if $thing's metaclass is a Moose::Meta::Role.

   is_class_ok $thing
       Passes if $thing's metaclass is a Moose::Meta::Class.

   is_anon_ok $thing
       Passes if $thing is "anonymous".

   is_not_anon_ok $thing
       Passes if $thing is not "anonymous".

   check_sugar_removed_ok $thing
       Ensures that all the standard Moose sugar is no longer directly callable on a given
       package.

   check_sugar_ok $thing
       Checks and makes sure a class/etc can still do all the standard Moose sugar.

   validate_thing
       Runs a bunch of tests against the given $thing, as defined:

           validate_thing $thing => (

               attributes => [ ... ],
               methods    => [ ... ],
               isa        => [ ... ],

               # ensures sugar is/is-not present
               sugar      => 0,

               # ensures $thing does these roles
               does       => [ ... ],

               # ensures $thing does not do these roles
               does_not   => [ ... ],
           );

       $thing can be the name of a role or class, an object instance, or a metaclass.

       ·   -subtest => 'subtest name...'

           If set, all tests run will be wrapped in a subtest, the name of which will be whatever
           "-subtest" is set to.

       ·   isa => [ ... ]

           A list of superclasses thing should have.

       ·   anonymous => 0|1

           Check to see if the class is/isn't anonymous.

       ·   does => [ ... ]

           A list of roles the thing should do.

       ·   does_not => [ ... ]

           A list of roles the thing should not do.

       ·   attributes => [ ... ]

           The attributes list specified here is in the form of a list of names, each optionally
           followed by a hashref of options to test the attribute for; this hashref takes the
           same arguments "validate_attribute" does.  e.g.:

               validate_thing $thing => (

                   attributes => [
                       'foo',
                       'bar',
                       baz => { is => 'ro', ... },
                       'bip',
                   ],
               );

       ·   methods => [ ... ]

           A list of methods the thing should have.

       ·   sugar => 0|1

           Ensure that thing can/cannot do the standard Moose sugar.

   validate_role
       The same as validate_thing(), but ensures $thing is a role, and allows for additional
       role-specific tests.

           validate_role $thing => (

               required_methods => [ ... ],

               # ...and all other options from validate_thing()
           );

       ·   -compose => 0|1

           When true, attempt to compose the role into an anonymous class, then use it to run
           "validate_class".  The options we're given are passed to validate_class() directly,
           except that any "required_methods" entry is removed and its contents pushed onto
           "methods".  (A stub method for each entry in "required_methods" will also be created
           in the new class.)

           e.g.:

               ok 1 - TestRole has a metaclass
               ok 2 - TestRole is a Moose role
               ok 3 - TestRole requires method blargh
               ok 4 - TestRole does TestRole
               ok 5 - TestRole does not do TestRole::Two
               ok 6 - TestRole has method method1
               ok 7 - TestRole has an attribute named bar
                   # Subtest: role composed into Moose::Meta::Class::__ANON__::SERIAL::1
                   ok 1 - Moose::Meta::Class::__ANON__::SERIAL::1 has a metaclass
                   ok 2 - Moose::Meta::Class::__ANON__::SERIAL::1 is a Moose class
                   ok 3 - Moose::Meta::Class::__ANON__::SERIAL::1 does TestRole
                   ok 4 - Moose::Meta::Class::__ANON__::SERIAL::1 does not do TestRole::Two
                   ok 5 - Moose::Meta::Class::__ANON__::SERIAL::1 has method method1
                   ok 6 - Moose::Meta::Class::__ANON__::SERIAL::1 has method blargh
                   ok 7 - Moose::Meta::Class::__ANON__::SERIAL::1 has an attribute named bar
                   1..7
               ok 8 - role composed into Moose::Meta::Class::__ANON__::SERIAL::1
               1..8

       ·   -subtest => 'subtest name...'

           If set, all tests run will be wrapped in a subtest, the name of which will be whatever
           "-subtest" is set to.

       ·   required_methods => [ ... ]

           A list of methods the role requires a consuming class to supply.

       ·   before => [ ... ]

           A list of methods the role expects to wrap before, on application to a class.

           See "before" in Moose for information on before method modifiers.

       ·   around => [ ... ]

           A list of methods the role expects to wrap around, on application to a class.

           See "around" in Moose for information on around method modifiers.

       ·   after => [ ... ]

           A list of methods the role expects to wrap after, on application to a class.

           See "after" in Moose for information on after method modifiers.

   validate_class
       The same as validate_thing(), but ensures $thing is a class, and allows for additional
       class-specific tests.

           validate_class $thing => (

               isa  => [ ... ],

               attributes => [ ... ],
               methods    => [ ... ],
               isa        => [ ... ],

               # ensures sugar is/is-not present
               sugar      => 0,

               # ensures $thing does these roles
               does       => [ ... ],

               # ensures $thing does not do these roles
               does_not   => [ ... ],

               # ...and all other options from validate_thing()
           );

       ·   -subtest => 'subtest name...'

           If set, all tests run will be wrapped in a subtest, the name of which will be whatever
           "-subtest" is set to.

       ·   immutable => 0|1

           Checks the class to see if it is/isn't immutable.

   validate_attribute
       validate_attribute() allows you to test how an attribute looks once built and attached to
       a class.

       Let's say you have an attribute defined like this:

           has foo => (
               traits  => [ 'TestRole' ],
               is      => 'ro',
               isa     => 'Int',
               builder => '_build_foo',
               lazy    => 1,
           );

       You can use validate_attribute() to ensure that it's built out in the way you expect:

           validate_attribute TestClass => foo => (

               # tests the attribute metaclass instance to ensure it does the roles
               -does => [ 'TestRole' ],
               # tests the attribute metaclass instance's inheritance
               -isa  => [ 'Moose::Meta::Attribute' ], # for demonstration's sake

               traits   => [ 'TestRole' ],
               isa      => 'Int',
               does     => 'Bar',
               handles  => { },
               reader   => 'foo',
               builder  => '_build_foo',
               default  => undef,
               init_arg => 'foo',
               lazy     => 1,
               required => undef,
           );

       Options passed to validate_attribute() prefixed with '-' test the attribute's metaclass
       instance rather than a setting on the attribute; that is, '-does' ensures that the
       metaclass does a particular role (e.g. MooseX::AttributeShortcuts), while 'does' tests the
       setting of the attribute to require the value do a given role.

       This function takes all the options "attribute_options_ok" takes, as well as the
       following:

       ·   -subtest => 'subtest name...'

           If set, all tests run will be wrapped in a subtest, the name of which will be whatever
           "-subtest" is set to.

   attribute_options_ok
       Validates that an attribute is set up as expected; like validate_attribute(), but only
       concerns itself with attribute options.

       Note that some of these options will skip if used against attributes defined in a role.

       ·   is => ro|rw

           Tests for reader/writer options set as one would expect.

       ·   isa => ...

           Validates that the attribute requires its value to be a given type.

       ·   does => ...

           Validates that the attribute requires its value to do a given role.

       ·   builder => '...'

           Validates that the attribute expects the method name given to be its builder.

       ·   default => ...

           Validates that the attribute has the given default.

       ·   init_arg => '...'

           Validates that the attribute has the given initial argument name.

       ·   lazy => 0|1

           Validates that the attribute is/isn't lazy.

       ·   required => 0|1

           Validates that setting the attribute's value is/isn't required.

SEE ALSO

       Please see those modules/websites for more information related to this module.

       ·   Test::Moose

BUGS

       Please report any bugs or feature requests on the bugtracker website
       https://github.com/RsrchBoy/Test-Moose-More/issues

       When submitting a bug or request, please include a test-file or a patch to an existing
       test-file that illustrates the bug or desired feature.

AUTHOR

       Chris Weyl <cweyl@alumni.drew.edu>

   I'm a material boy in a material world
       Please note I do not expect to be gittip'ed or flattr'ed for this work, rather it is
       simply a very pleasant surprise. I largely create and release works like this because I
       need them or I find it enjoyable; however, don't let that stop you if you feel like it ;)

       Flattr
       <https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2FTest-
       Moose-More&title=RsrchBoy's%20CPAN%20Test-Moose-More&tags=%22RsrchBoy's%20Test-Moose-
       More%20in%20the%20CPAN%22>, Gratipay <https://gratipay.com/RsrchBoy/>, or indulge my
       Amazon Wishlist <http://bit.ly/rsrchboys-wishlist>...  If and *only* if you so desire.

CONTRIBUTORS

       ·   Chad Granum <chad.granum@dreamhost.com>

       ·   Karen Etheridge <ether@cpan.org>

COPYRIGHT AND LICENSE

       This software is Copyright (c) 2012 by Chris Weyl.

       This is free software, licensed under:

         The GNU Lesser General Public License, Version 2.1, February 1999