Skip to content

Commit

Permalink
added a few more command tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 3, 2011
1 parent b0a1868 commit 777a377
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/Command.pm
Expand Up @@ -58,7 +58,7 @@ sub class_to_file {

sub class_to_path {
my ($self, $class) = @_;
my $path = join '/', split /::/, $class;
my $path = join '/', split /::|'/, $class;
return "$path.pm";
}
Expand Down
9 changes: 7 additions & 2 deletions t/mojo/command.t
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use Mojo::Base -strict;

use Test::More tests => 27;
use Test::More tests => 32;

use Cwd 'cwd';
use File::Spec;
Expand Down Expand Up @@ -67,7 +67,12 @@ is $command->class_to_file('FooBAR'), 'foo_bar', 'right file';
is $command->class_to_file('Foo::BAR'), 'foo_bar', 'right file';

# Class to path
is $command->class_to_path('Foo::Bar'), 'Foo/Bar.pm', 'right path';
is $command->class_to_path('Foo::Bar'), 'Foo/Bar.pm', 'right path';
is $command->class_to_path("Foo'Bar"), 'Foo/Bar.pm', 'right path';
is $command->class_to_path("Foo'Bar::Baz"), 'Foo/Bar/Baz.pm', 'right path';
is $command->class_to_path("Foo::Bar'Baz"), 'Foo/Bar/Baz.pm', 'right path';
is $command->class_to_path("Foo::Bar::Baz"), 'Foo/Bar/Baz.pm', 'right path';
is $command->class_to_path("Foo'Bar'Baz"), 'Foo/Bar/Baz.pm', 'right path';

# Environment detection
{
Expand Down
8 changes: 6 additions & 2 deletions t/mojo/loader.t
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use Mojo::Base -strict;

use Test::More tests => 36;
use Test::More tests => 38;

use FindBin;
use lib "$FindBin::Bin/lib";
Expand Down Expand Up @@ -67,4 +67,8 @@ ok !!LoaderTest::B->can('new'), 'loaded successfully';
ok !!LoaderTest::C->can('new'), 'loaded successfully';

# Class does not exist
ok $loader->load('LoaderTest'), 'nothing to load';
ok !!$loader->load('LoaderTest'), 'nothing to load';

# Invalid class
ok !!$loader->load('Mojolicious/Lite'), 'nothing to load';
ok !$loader->load('Mojolicious::Lite'), 'loaded successfully';

0 comments on commit 777a377

Please sign in to comment.