Skip to content

Commit

Permalink
fix to work with v6 of Mojolicious
Browse files Browse the repository at this point in the history
this is largely overriding the methods in Test::Mojo::More to make
it work (need to ignore some POD::Coverage tests when doing this)
  • Loading branch information
leejo committed Feb 25, 2015
1 parent c427e58 commit a4c886d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Revision history for Test-Mojo-Most

0.06 2015-02-25
- Fix to work with v6 of Mojolicious - involves overriding some of
the methods used by Test::Mojo::More

0.05 2014-09-06
- Fix Kwalitee issues in distribution

Expand Down
2 changes: 1 addition & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ WriteMakefile(
LICENSE => 'perl',
MIN_PERL_VERSION => '5.10.1',
PREREQ_PM => {
'Test::Mojo::Session' => 1.01,
'Test::Mojo::Session' => 1.03,
'Test::Mojo::More' => 0.05,
'Test::Mojo::Trim' => 0.03,
},
Expand Down
27 changes: 25 additions & 2 deletions lib/Test/Mojo/Most.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,27 @@ use parent 'Test::Mojo::Session';
use parent 'Test::Mojo::More';
use parent 'Test::Mojo::Trim';

our $VERSION = '0.05';
our $VERSION = '0.06';

sub _cookie {
my ( $self,$name ) = @_;
foreach my $cookie ( $self->ua->cookie_jar->all ) {
return $cookie if $cookie->name eq $name;
}
return;
}

sub _session {
return shift->_extract_session;
}

sub _flash {
return shift->_cookie( @_ ) if @_ == 2;
return {};
}

sub cookie_hashref { return { map { $_->name => $_->value } @{ $_[0]->tx->res->cookies } } }
sub flash_hashref { return $_[0]->_session->{flash} || $_[0]->_session->{new_flash} || {} }

__END__
Expand Down Expand Up @@ -48,7 +68,10 @@ L<Test::Most> but for Mojo
Test::Mojo::Most is an extension for L<Test::Mojo>, it inherits all methods
from L<Test::Mojo>, L<Test::Mojo::Session>, L<Test::Mojo::Trim>, and
L<Test::Mojo::More>. It will add more Test::Mojo:: modules as they become
available
available.
This module also fixes L<Test::Mojo::More> to use the correct values when
retrieving the cookies / session / flash values
=head1 SEE ALSO
Expand Down
2 changes: 1 addition & 1 deletion t/001_compiles_pod.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ for my $file (@files) {
my $module = $file; $module =~ s,\.pm$,,; $module =~ s,.*/?lib/,,; $module =~ s,/,::,g;
ok eval "use $module; 1", "use $module" or diag $@;
Test::Pod::pod_file_ok($file);
Test::Pod::Coverage::pod_coverage_ok($module);
Test::Pod::Coverage::pod_coverage_ok($module,{ also_private => [ qw/cookie_hashref flash_hashref/ ] });
}

0 comments on commit a4c886d

Please sign in to comment.