summaryrefslogtreecommitdiffstats
path: root/t/moose/moose_cookbook_extending_recipe4.t
blob: 1a410937ff3e8dc33f6ca2216539c716740af7ba (plain) (blame)
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
67
#!/usr/bin/perl -w

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



# =begin testing SETUP
{

  package MyApp::Mooseish;

  use Moose ();
  use MooseX::Exporter::Easy;

  also 'Moose';

  sub init_meta_extra {
      shift;
      return Moose->init_meta( @_, metaclass => 'MyApp::Meta::Class' );
  }

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

  export;

  package MyApp::Meta::Class;
  use Moose;

  extends 'Moose::Meta::Class';

  has 'table' => ( is => 'rw' );
}



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

    MyApp::Mooseish->import;

    has_table( 'User' );

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

    sub login { }
}

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




1;