View on
MetaCPAN
Paul Boyd > MooseX-Test-Role-0.02 > MooseX::Test::Role

Download:
MooseX-Test-Role-0.02.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.02   Source   Latest Release: MooseX-Test-Role-0.08

NAME ^

MooseX::Test::Role - Test functions for Moose roles

SYNOPSIS ^

  use MooseX::Test::Role;
  use Test::More tests => 2;

  requires_ok('MyRole', qw/method1 method2/);

  my $consumer = consumer_of('MyRole', method1 => sub { 1 });
  ok($consumer->myrole_method);
  is($consumer->method1, 1);

DESCRIPTION ^

Provides functions for testing roles.

EXPORTED FUNCTIONS ^

consumer_of ($role, %methods)

Creates an instance of a class which consumes the role. Required methods are stubbed, they return undef by default.

To add additional methods to the instance specify the name and coderef:

  consumer_of('MyRole',
      method1 => sub { 'one' },
      method2 => sub { 'two' },
      required_method => sub { 'required' },
  );
requires_ok ($role, @methods)

Tests if role requires one or more methods.

AUTHOR ^

Paul Boyd <pboyd@dev3l.net>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2011 by Paul Boyd.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: