Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test::Class::Moose::Role::AutoUse and no corresponding base class #33

Open
Ovid opened this issue May 14, 2014 · 0 comments
Open

Test::Class::Moose::Role::AutoUse and no corresponding base class #33

Ovid opened this issue May 14, 2014 · 0 comments

Comments

@Ovid
Copy link
Contributor

Ovid commented May 14, 2014

When I write a base class, it's often something like:

package TestsFor::SomeCompany;

use Test::Class::Moose;
with qw(Test::Class::Moose::Role::Autouse);

1;

That's always worked (so far) because there's almost always a corresponding SomeCompany.pm file. Today that turned out to not be the case. However, we should try to decouple that and have the autouse role recognize when we don't need a corresponding class. This was a coupling mistake I made and am thinking about a clean solution for the fix. Until then, the following workaround in your TCM base class should suffice:

around 'get_class_name_to_use' => sub {
    my $orig = shift;
    my $self = shift;

    if ( __PACKAGE__ eq ref $self ) {
        return '';
    }
    return $self->$orig(@_);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant