fix typo in docs: . instead of ;
[gitmo/Moose.git] / t / 200_examples / 002_example_Moose_POOP.t
index 81b6e5d..8d6e28a 100644 (file)
@@ -5,14 +5,12 @@ use warnings;
 
 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
@@ -36,7 +34,7 @@ of the ::Instance protocol.
 
 BEGIN {
 
-    package Moose::POOP::Meta::Instance;
+    package MooseX::POOP::Meta::Instance;
     use Moose;
 
     use DBM::Deep;
@@ -130,7 +128,7 @@ BEGIN {
         sprintf "%s->{instance}->{%s}", $instance, $slot_name;
     }
 
-    package Moose::POOP::Meta::Class;
+    package MooseX::POOP::Meta::Class;
     use Moose;
 
     extends 'Moose::Meta::Class';
@@ -145,9 +143,9 @@ BEGIN {
 
 }
 {
-    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;
 
@@ -163,7 +161,7 @@ BEGIN {
     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');
@@ -174,7 +172,7 @@ BEGIN {
 
     use DateTime::Format::MySQL;
 
-    extends 'Moose::POOP::Object';
+    extends 'MooseX::POOP::Object';
 
     subtype 'Headline'
         => as 'Str'
@@ -210,36 +208,36 @@ BEGIN {
 }
 
 { # 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',
@@ -252,26 +250,26 @@ my $article_ref;
 
             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');
 
@@ -296,13 +294,13 @@ my $article_ref;
     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',
@@ -315,9 +313,9 @@ my $article2_ref;
 
             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";
@@ -342,11 +340,11 @@ my $article2_ref;
     ## 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');
@@ -366,10 +364,10 @@ my $article2_ref;
     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');
@@ -377,15 +375,15 @@ my $article2_ref;
     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');
@@ -408,11 +406,11 @@ Moose::POOP::Meta::Instance->_reload_db();
     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');