[libcatmandu-perl] 35/85: rewrite pluggable tests
Jonas Smedegaard
dr at jones.dk
Tue May 20 09:56:17 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.91
in repository libcatmandu-perl.
commit 941d13a3f8508a6a655402c67186a6f047eddcf1
Author: Nicolas Steenlant <nicolas.steenlant at ugent.be>
Date: Mon May 12 16:00:47 2014 +0200
rewrite pluggable tests
---
lib/Catmandu/Pluggable.pm | 4 ++--
t/Catmandu-Pluggable.t | 39 ++++++++++++++++++++++-----------------
2 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/lib/Catmandu/Pluggable.pm b/lib/Catmandu/Pluggable.pm
index c3fd863..cb4ffa4 100644
--- a/lib/Catmandu/Pluggable.pm
+++ b/lib/Catmandu/Pluggable.pm
@@ -1,8 +1,8 @@
package Catmandu::Pluggable;
-use namespace::clean;
use Catmandu::Sane;
use Role::Tiny;
+use namespace::clean;
sub plugin_namespace { 'Catmandu::Plugin' }
@@ -13,7 +13,7 @@ sub with_plugins {
@plugins = split /,/, join ',', @plugins;
@plugins || return $class;
my $ns = $class->plugin_namespace;
- Moo::Role->create_class_with_roles($class, map {
+ Role::Tiny->create_class_with_roles($class, map {
my $pkg = $_;
if ($pkg !~ s/^\+// && $pkg !~ /^$ns/) {
$pkg = "${ns}::${pkg}";
diff --git a/t/Catmandu-Pluggable.t b/t/Catmandu-Pluggable.t
index ca88708..628f047 100644
--- a/t/Catmandu-Pluggable.t
+++ b/t/Catmandu-Pluggable.t
@@ -1,34 +1,39 @@
#!/usr/bin/env perl
-package Catmandu::Plugin::Test;
-use Moo::Role;
-
-sub test {
- "ok";
-}
-
-package main;
use strict;
use warnings;
use Test::More;
use Test::Exception;
-use Catmandu::Store::Hash;
my $pkg;
BEGIN {
$pkg = 'Catmandu::Pluggable';
use_ok $pkg;
}
-require_ok $pkg;
-my $store = Catmandu::Store::Hash->new();
-ok $store , 'new store';
+{
+ package Catmandu::Plugin::Frangle;
+ use Moo::Role;
+ sub frangle {
+ "frangle";
+ }
+
+ package T::Pluggable;
+ use Moo;
+ with $pkg;
+}
+
+my $t = T::Pluggable->new;
+
+can_ok $t, 'plugin_namespace';
+can_ok $t, 'with_plugins';
+is $t->plugin_namespace, 'Catmandu::Plugin';
+dies_ok { $t->frangle } "original instance doesn't have plugin";
+
+my $t_plugged = $t->with_plugins('Frangle');
-my $bag = $store->bag->with_plugins('Test');
-ok $bag , 'bag with Test plugin';
-can_ok $bag , 'test';
-is $bag->test , 'ok' , 'bag->test';
-dies_ok { $store->bag->test } 'original bag doesnt have plugin';
+ok $t_plugged, 'instance with plugin';
+can_ok $t_plugged, 'frangle';
done_testing 7;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-perl.git
More information about the Pkg-perl-cvs-commits
mailing list