| 1 | package Mojolicious::Plugin::Prove; | ||||||||||||
| 2 | 8 | $Mojolicious::Plugin::Prove::VERSION = '0.11'; | |||||||||||
| 3 | # ABSTRACT: run test scripts via browser | ||||||||||||
| 4 | |||||||||||||
| 5 | 8 | ▶ | use Mojo::Base 'Mojolicious::Plugin::Prove::Base'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 8 | ▶ | use Mojo::File; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 8 | ▶ | sub register { | ||||||||||
|
Subroutine
register: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||
| 9 | 8 | my ($self, $app, $conf) = @_; | |||||||||||
| 10 | |||||||||||||
| 11 | # we need configuration hash that looks like | ||||||||||||
| 12 | # { | ||||||||||||
| 13 | # prefix => 'prove', | ||||||||||||
| 14 | # tests => { | ||||||||||||
| 15 | # name => '/testdir', | ||||||||||||
| 16 | # name2 => '/other/dir', | ||||||||||||
| 17 | # } | ||||||||||||
| 18 | # } | ||||||||||||
| 19 | |||||||||||||
| 20 | # Add template path | ||||||||||||
| 21 | 8 | $self->add_template_path($app->renderer, __PACKAGE__); | |||||||||||
| 22 | |||||||||||||
| 23 | # Add public path | ||||||||||||
| 24 | 8 | my $static_path = Mojo::File->new(__FILE__)->sibling('Prove', 'public' )->to_string; | |||||||||||
| 25 | 8 | push @{ $app->static->paths }, $static_path; | |||||||||||
| 26 | |||||||||||||
| 27 | 8 | $app->plugin( 'PPI' => { no_check_file => 1 } ); | |||||||||||
| 28 | |||||||||||||
| 29 | # Routes | ||||||||||||
| 30 | 8 | my $r = $app->routes; | |||||||||||
| 31 | 8 | ▶ | $r = $conf->{route} if $conf->{route}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 32 | 8 | ▶ | my $prefix = $conf->{prefix} // 'prove'; | ||||||||||
|
Condition100%2/2
$conf->{"prefix"} // "prove"
MC/DC100%1/1
$conf->{"prefix"} // "prove"
$conf->{"prefix"}
Truth table100%2/2
A
A= $conf->{"prefix"}
| |||||||||||||
| 33 | |||||||||||||
| 34 | 8 | $self->prefix($prefix); | |||||||||||
| 35 | 8 | ▶ | $self->conf( $conf->{tests} || {} ); | ||||||||||
|
Condition100%2/2
$conf->{'tests'} || {}
MC/DC100%1/1
$conf->{'tests'} || {}
$conf->{'tests'}
Truth table100%2/2
A
A= $conf->{'tests'}
| |||||||||||||
| 36 | |||||||||||||
| 37 | |||||||||||||
| 38 | { | ||||||||||||
| 39 | 8 | my $pr = $r->any("/$prefix")->to( | |||||||||||
| 40 | 'controller#', | ||||||||||||
| 41 | namespace => 'Mojolicious::Plugin::Prove', | ||||||||||||
| 42 | plugin => $self, | ||||||||||||
| 43 | prefix => $self->prefix, | ||||||||||||
| 44 | conf => $self->conf, | ||||||||||||
| 45 | ); | ||||||||||||
| 46 | |||||||||||||
| 47 | 8 | $pr->get('/')->to( '#list' )->name('mpp_prove_list'); | |||||||||||
| 48 | 8 | $pr->get('/test/*name/file/*file/run')->to( '#run' )->name('mpp_run_file'); | |||||||||||
| 49 | 8 | $pr->get('/test/*name/file/*file')->to( '#file' )->name('mpp_file'); | |||||||||||
| 50 | 8 | $pr->get('/test/*name/run')->to( '#run' )->name('mpp_run_all'); | |||||||||||
| 51 | 8 | $pr->get('/test/*name')->to( '#list' )->name('mpp_file_list'); | |||||||||||
| 52 | } | ||||||||||||
| 53 | } | ||||||||||||
| 54 | |||||||||||||
| 55 | 8 | 1; | |||||||||||
| 56 | |||||||||||||
| 57 | __END__ | ||||||||||||