work in progress, tests are failing, and parameterized role is not flexible enough...
[gitmo/MooseX-Getopt.git] / t / 108_usage_attr.t
CommitLineData
81b19ed8 1#!/usr/bin/env perl
2
3# Re RT#58715 and the claim in the documentation:
4# If you have Getopt::Long::Descriptive the usage param is also passed to new.
5
6# This tests the fix (that fulfills the documentation claim).
7
8use strict; use warnings;
9use Test::More tests => 3;
10
11{
12 package MyClass;
13 use strict; use warnings;
14 use Moose;
15 with 'MooseX::Getopt';
16}
17
18Moose::Meta::Class->create('MyClassWithBasic',
19 superclasses => ['MyClass'],
20 roles => [ 'MooseX::Getopt::Basic' ],
21);
22
23my $basic_obj = MyClassWithBasic->new_with_options();
24ok(!$basic_obj->meta->has_attribute('usage'), 'basic class has no usage attribute');
25
26Moose::Meta::Class->create('MyClassWithGLD',
27 superclasses => ['MyClass'],
28 roles => [ 'MooseX::Getopt' ],
29);
30
31my $gld_obj = MyClassWithGLD->new_with_options();
32
33ok($gld_obj->meta->has_attribute('usage'), 'class has usage attribute');
34isa_ok($gld_obj->usage, 'Getopt::Long::Descriptive::Usage');
35