use Test::More;
-BEGIN {
- eval "use DBM::Deep 1.0003;";
- plan skip_all => "DBM::Deep 1.0003 (or greater) is required for this test" if $@;
- eval "use DateTime::Format::MySQL;";
- plan skip_all => "DateTime::Format::MySQL is required for this test" if $@;
-}
+use Test::Requires {
+ 'DBM::Deep' => '1.0003', # skip all if not installed
+ 'DateTime::Format::MySQL' => '0.01',
+};
-use Test::Exception;
+use Test::Fatal;
BEGIN {
# in case there are leftovers
BEGIN {
- package Moose::POOP::Meta::Instance;
+ package MooseX::POOP::Meta::Instance;
use Moose;
use DBM::Deep;
sprintf "%s->{instance}->{%s}", $instance, $slot_name;
}
- package Moose::POOP::Meta::Class;
+ package MooseX::POOP::Meta::Class;
use Moose;
extends 'Moose::Meta::Class';
}
{
- package Moose::POOP::Object;
- use metaclass 'Moose::POOP::Meta::Class' => (
- instance_metaclass => 'Moose::POOP::Meta::Instance'
+ package MooseX::POOP::Object;
+ use metaclass 'MooseX::POOP::Meta::Class' => (
+ instance_metaclass => 'MooseX::POOP::Meta::Instance'
);
use Moose;
package Newswriter::Author;
use Moose;
- extends 'Moose::POOP::Object';
+ extends 'MooseX::POOP::Object';
has 'first_name' => (is => 'rw', isa => 'Str');
has 'last_name' => (is => 'rw', isa => 'Str');
use DateTime::Format::MySQL;
- extends 'Moose::POOP::Object';
+ extends 'MooseX::POOP::Object';
subtype 'Headline'
=> as 'Str'
}
{ # check the meta stuff first
- isa_ok(Moose::POOP::Object->meta, 'Moose::POOP::Meta::Class');
- isa_ok(Moose::POOP::Object->meta, 'Moose::Meta::Class');
- isa_ok(Moose::POOP::Object->meta, 'Class::MOP::Class');
+ isa_ok(MooseX::POOP::Object->meta, 'MooseX::POOP::Meta::Class');
+ isa_ok(MooseX::POOP::Object->meta, 'Moose::Meta::Class');
+ isa_ok(MooseX::POOP::Object->meta, 'Class::MOP::Class');
- is(Moose::POOP::Object->meta->instance_metaclass,
- 'Moose::POOP::Meta::Instance',
+ is(MooseX::POOP::Object->meta->instance_metaclass,
+ 'MooseX::POOP::Meta::Instance',
'... got the right instance metaclass name');
- isa_ok(Moose::POOP::Object->meta->get_meta_instance, 'Moose::POOP::Meta::Instance');
+ isa_ok(MooseX::POOP::Object->meta->get_meta_instance, 'MooseX::POOP::Meta::Instance');
- my $base = Moose::POOP::Object->new;
- isa_ok($base, 'Moose::POOP::Object');
+ my $base = MooseX::POOP::Object->new;
+ isa_ok($base, 'MooseX::POOP::Object');
isa_ok($base, 'Moose::Object');
- isa_ok($base->meta, 'Moose::POOP::Meta::Class');
+ isa_ok($base->meta, 'MooseX::POOP::Meta::Class');
isa_ok($base->meta, 'Moose::Meta::Class');
isa_ok($base->meta, 'Class::MOP::Class');
is($base->meta->instance_metaclass,
- 'Moose::POOP::Meta::Instance',
+ 'MooseX::POOP::Meta::Instance',
'... got the right instance metaclass name');
- isa_ok($base->meta->get_meta_instance, 'Moose::POOP::Meta::Instance');
+ isa_ok($base->meta->get_meta_instance, 'MooseX::POOP::Meta::Instance');
}
my $article_oid;
my $article_ref;
{
my $article;
- lives_ok {
+ is( exception {
$article = Newswriter::Article->new(
headline => 'Home Office Redecorated',
summary => 'The home office was recently redecorated to match the new company colors',
status => 'pending'
);
- } '... created my article successfully';
+ }, undef, '... created my article successfully' );
isa_ok($article, 'Newswriter::Article');
- isa_ok($article, 'Moose::POOP::Object');
+ isa_ok($article, 'MooseX::POOP::Object');
- lives_ok {
+ is( exception {
$article->start_date(DateTime->new(year => 2006, month => 6, day => 10));
$article->end_date(DateTime->new(year => 2006, month => 6, day => 17));
- } '... add the article date-time stuff';
+ }, undef, '... add the article date-time stuff' );
## check some meta stuff
- isa_ok($article->meta, 'Moose::POOP::Meta::Class');
+ isa_ok($article->meta, 'MooseX::POOP::Meta::Class');
isa_ok($article->meta, 'Moose::Meta::Class');
isa_ok($article->meta, 'Class::MOP::Class');
is($article->meta->instance_metaclass,
- 'Moose::POOP::Meta::Instance',
+ 'MooseX::POOP::Meta::Instance',
'... got the right instance metaclass name');
- isa_ok($article->meta->get_meta_instance, 'Moose::POOP::Meta::Instance');
+ isa_ok($article->meta->get_meta_instance, 'MooseX::POOP::Meta::Instance');
ok($article->oid, '... got a oid for the article');
is($article->status, 'pending', '... got the right status');
}
-Moose::POOP::Meta::Instance->_reload_db();
+MooseX::POOP::Meta::Instance->_reload_db();
my $article2_oid;
my $article2_ref;
{
my $article2;
- lives_ok {
+ is( exception {
$article2 = Newswriter::Article->new(
headline => 'Company wins Lottery',
summary => 'An email was received today that informed the company we have won the lottery',
status => 'posted'
);
- } '... created my article successfully';
+ }, undef, '... created my article successfully' );
isa_ok($article2, 'Newswriter::Article');
- isa_ok($article2, 'Moose::POOP::Object');
+ isa_ok($article2, 'MooseX::POOP::Object');
$article2_oid = $article2->oid;
$article2_ref = "$article2";
## orig-article
my $article;
- lives_ok {
+ is( exception {
$article = Newswriter::Article->new(oid => $article_oid);
- } '... (re)-created my article successfully';
+ }, undef, '... (re)-created my article successfully' );
isa_ok($article, 'Newswriter::Article');
- isa_ok($article, 'Moose::POOP::Object');
+ isa_ok($article, 'MooseX::POOP::Object');
is($article->oid, $article_oid, '... got a oid for the article');
isnt($article_ref, "$article", '... got a new article instance');
is($article->author->first_name, 'Truman', '... got the right author first name');
is($article->author->last_name, 'Capote', '... got the right author last name');
- lives_ok {
+ is( exception {
$article->author->first_name('Dan');
$article->author->last_name('Rather');
- } '... changed the value ok';
+ }, undef, '... changed the value ok' );
is($article->author->first_name, 'Dan', '... got the changed author first name');
is($article->author->last_name, 'Rather', '... got the changed author last name');
is($article->status, 'pending', '... got the right status');
}
-Moose::POOP::Meta::Instance->_reload_db();
+MooseX::POOP::Meta::Instance->_reload_db();
{
my $article;
- lives_ok {
+ is( exception {
$article = Newswriter::Article->new(oid => $article_oid);
- } '... (re)-created my article successfully';
+ }, undef, '... (re)-created my article successfully' );
isa_ok($article, 'Newswriter::Article');
- isa_ok($article, 'Moose::POOP::Object');
+ isa_ok($article, 'MooseX::POOP::Object');
is($article->oid, $article_oid, '... got a oid for the article');
isnt($article_ref, "$article", '... got a new article instance');
is($article->status, 'pending', '... got the right status');
my $article2;
- lives_ok {
+ is( exception {
$article2 = Newswriter::Article->new(oid => $article2_oid);
- } '... (re)-created my article successfully';
+ }, undef, '... (re)-created my article successfully' );
isa_ok($article2, 'Newswriter::Article');
- isa_ok($article2, 'Moose::POOP::Object');
+ isa_ok($article2, 'MooseX::POOP::Object');
is($article2->oid, $article2_oid, '... got a oid for the article');
isnt($article2_ref, "$article2", '... got a new article instance');