From 636f22f307ff0dc94a2c2ec23d49c872ecddbc02 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 19 Jul 2010 19:10:14 -0500 Subject: initial implementation --- t/moose/moose_cookbook_extending_recipe4.t | 67 ++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 t/moose/moose_cookbook_extending_recipe4.t (limited to 't/moose/moose_cookbook_extending_recipe4.t') diff --git a/t/moose/moose_cookbook_extending_recipe4.t b/t/moose/moose_cookbook_extending_recipe4.t new file mode 100644 index 0000000..1a41093 --- /dev/null +++ b/t/moose/moose_cookbook_extending_recipe4.t @@ -0,0 +1,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; -- cgit v1.2.3-54-g00ecf