summaryrefslogtreecommitdiff
path: root/t/recipes/extending_mooseish_moosesugar.t
blob: fd003c91b6be24d76fa8e6f95abd1002adb45592 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl -w

use strict;
use Test::More 'no_plan';
use Test::Fatal;
$| = 1;



# =begin testing SETUP
{

  package MyApp::Mooseish;

  use Moose::Exporter;

  Moose::Exporter->setup_import_methods(
      with_meta       => ['has_table'],
      class_metaroles => {
          class => ['MyApp::Meta::Class::Trait::HasTable'],
      },
  );

  sub has_table {
      my $meta = shift;
      $meta->table(shift);
  }

  package MyApp::Meta::Class::Trait::HasTable;
  use Moose::Role;

  has table => (
      is  => 'rw',
      isa => 'Str',
  );
}



# =begin testing
{
{
    package MyApp::User;

    use Moose;
    MyApp::Mooseish->import;

    has_table( 'User' );

    has( 'username' => ( is => 'ro' ) );
    has( 'password' => ( is => 'ro' ) );

    sub login { }
}

can_ok( MyApp::User->meta, 'table' );
is( MyApp::User->meta->table, 'User',
    'MyApp::User->meta->table returns User' );
ok( MyApp::User->can('username'),
    'MyApp::User has username method' );
}




1;