role test case
John Napiorkowski [Tue, 11 Aug 2015 19:23:05 +0000 (14:23 -0500)]
t/arg_constraints.t

index 2a005b7..cb4d8cf 100644 (file)
@@ -43,6 +43,23 @@ BEGIN {
 }
 
 {
+  package MyApp::Role::Controller;
+  $INC{'MyApp/Role/Controller.pm'} = __FILE__;
+
+  use Moose::Role;
+  use MooseX::MethodAttributes::Role;
+  use MyApp::Types qw/Int Str/;
+
+  sub role_str :Path('role_test') Args(Str) {
+    my ($self, $c, $arg) = @_;
+    $c->res->body('role_str'.$arg);
+  }
+
+  sub role_int :Path('role_test') Args(Int) {
+    my ($self, $c, $arg) = @_;
+    $c->res->body('role_int'.$arg);
+  }
+
   package MyApp::Model::User;
   $INC{'MyApp/Model/User.pm'} = __FILE__;
 
@@ -70,6 +87,8 @@ BEGIN {
   use MyApp::Types qw/Tuple Int Str StrMatch ArrayRef UserId User Heart/;
 
   extends 'Catalyst::Controller';
+  with 'MyApp::Role::Controller';
+
 
   sub user :Local Args(UserId) {
     my ($self, $c, $int) = @_;
@@ -476,4 +495,17 @@ SKIP: {
 
 }
 
+# Test Roles
+
+{
+    my $res = request '/role_test/1';
+    is $res->content, 'role_int1';
+}
+
+{
+    my $res = request '/role_test/a';
+    is $res->content, 'role_stra';
+}
+
+
 done_testing;