Add a nice loud warning for idiots like me who type the wrong thing all the time
[gitmo/MooseX-Types-Common.git] / t / 03-idiot.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5
6 # Test for a warning when you make the stupid mistake I make all the time
7 # of saying use MooseX::Types::Common qw/NonEmptySimpleStr/;
8
9 BEGIN {
10     eval { require Capture::Tiny }
11         or plan skip_all => 'Capture::Tiny needed for these tests';
12 }
13
14 plan tests => 4;
15
16 use_ok 'MooseX::Types::Common';
17
18 my ($stdout, $stderr) = Capture::Tiny::capture(sub {
19     MooseX::Types::Common->import;
20 });
21 is $stderr, '', 'No warning if nothing imported';
22
23 ($stdout, $stderr) = Capture::Tiny::capture(sub {
24     MooseX::Types::Common->import('NonEmptySimpleStr');
25 });
26 like $stderr, qr/Did you mean/, 'Got warning';
27 like $stderr, qr/NonEmptySimpleStr/, 'Warning mentions bad type';
28