stop using Moo as a test package
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Moose.pm
index 5783686..705b2bd 100644 (file)
@@ -2,40 +2,32 @@ package TestApp::Controller::Moose;
 
 use Moose;
 
+use namespace::clean -except => 'meta';
+
 BEGIN { extends qw/Catalyst::Controller/; }
+use MooseX::MethodAttributes; # FIXME - You need to say this if you have
+                              #         modifiers so that you get the correct
+                              #         method metaclass, why does the modifier
+                              #         on MODIFY_CODE_ATTRIBUTES not work.
 
-has attribute => ( # Test defaults work
+has attribute => (
     is      => 'ro',
     default => 42,
 );
 
-has other_attribute => ( # Test BUILD method is called
-    is => 'rw'
-);
-
-has punctuation => ( # Test BUILD method gets merged config
-    is => 'rw'
-);
-
-has space => ( # Test that attribute slots get filled from merged config
-    is => 'ro'
-);
-
-no Moose;
-
-__PACKAGE__->config(the_punctuation => ':');
-__PACKAGE__->config(space => ' '); # i am pbp, icm5ukp
-
-sub BUILD {
-    my ($self, $config) = @_;
-    # Note, not an example of something you would ever
-    $self->other_attribute('the meaning of life');
-    $self->punctuation( $config->{the_punctuation} );
+sub get_attribute : Local {
+    my ($self, $c) = @_;
+    $c->response->body($self->attribute);
 }
 
-sub the_answer : Local {
+sub with_local_modifier : Local {
     my ($self, $c) = @_;
-    $c->response->body($self->other_attribute . $self->punctuation . $self->space . $self->attribute);
+    $c->forward('get_attribute');
 }
 
+before with_local_modifier => sub {
+    my ($self, $c) = @_;
+    $c->response->header( 'X-Catalyst-Test-Before' => 'before called' );
+};
+
 1;