| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package KelpX::Symbiosis::Test; |
|
2
|
|
|
|
|
|
|
$KelpX::Symbiosis::Test::VERSION = '2.11'; |
|
3
|
14
|
|
|
14
|
|
1938966
|
use Kelp::Base; |
|
|
14
|
|
|
|
|
931991
|
|
|
|
14
|
|
|
|
|
109
|
|
|
4
|
14
|
|
|
14
|
|
11666
|
use Kelp::Test; |
|
|
14
|
|
|
|
|
152912
|
|
|
|
14
|
|
|
|
|
73
|
|
|
5
|
14
|
|
|
14
|
|
667
|
use Carp; |
|
|
14
|
|
|
|
|
27
|
|
|
|
14
|
|
|
|
|
6508
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
attr "-app" => sub { die "`app` parameter is required" }; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub wrap |
|
10
|
|
|
|
|
|
|
{ |
|
11
|
13
|
|
|
13
|
1
|
35824
|
my ($class, %args) = @_; |
|
12
|
13
|
|
|
|
|
101
|
my $self = $class->new(%args); |
|
13
|
|
|
|
|
|
|
|
|
14
|
13
|
50
|
|
|
|
128
|
die 'This is not a Kelp app' |
|
15
|
|
|
|
|
|
|
unless $self->app->isa('Kelp'); |
|
16
|
13
|
50
|
|
|
|
266
|
die 'This Kelp app does not have Symbiosis' |
|
17
|
|
|
|
|
|
|
unless $self->app->can('symbiosis'); |
|
18
|
|
|
|
|
|
|
|
|
19
|
13
|
|
|
|
|
236
|
return Kelp::Test->new(app => $self); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub run |
|
23
|
|
|
|
|
|
|
{ |
|
24
|
56
|
|
|
56
|
0
|
564251
|
shift->app->run_all(@_); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub can |
|
28
|
|
|
|
|
|
|
{ |
|
29
|
30
|
|
|
30
|
0
|
267545
|
my ($self, $func) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
30
|
100
|
|
|
|
111
|
if (ref $self) { |
|
32
|
2
|
|
|
|
|
6
|
my $can = $self->app->can($func); |
|
33
|
2
|
50
|
|
|
|
18
|
return $can if defined $can; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
28
|
|
|
|
|
212
|
return $self->SUPER::can($func); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub AUTOLOAD |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
62
|
|
|
62
|
|
749371
|
my $self = shift; |
|
42
|
|
|
|
|
|
|
|
|
43
|
62
|
|
|
|
|
176
|
my $func = our $AUTOLOAD; |
|
44
|
62
|
100
|
|
|
|
1504
|
return if $func =~ /::DESTROY$/; |
|
45
|
48
|
|
|
|
|
329
|
$func =~ s/.*:://; |
|
46
|
|
|
|
|
|
|
|
|
47
|
48
|
|
|
|
|
177
|
my $method = $self->app->can($func); |
|
48
|
48
|
50
|
|
|
|
549
|
die "Kelp cannot $func" unless $method; |
|
49
|
48
|
|
|
|
|
162
|
$method->($self->app, @_); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
|
53
|
|
|
|
|
|
|
__END__ |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
KelpX::Symbiosis::Test - Allow testing symbiotic environments using Kelp::Test |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# in test file |
|
62
|
|
|
|
|
|
|
use KelpX::Symbiosis::Test; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $t = KelpX::Symbiosis::Test->wrap(app => $kelp_app); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# continue testing using $t, just like Kelp::Test |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This module allows testing Kelp apps with Symbiosis using L<Kelp::Test>. The |
|
71
|
|
|
|
|
|
|
problem with I<Kelp::Test> is that it automatically runs I<run()> on the app |
|
72
|
|
|
|
|
|
|
without any way to configure this behavior. Symbiotic apps use I<run_all()> to |
|
73
|
|
|
|
|
|
|
run the whole environment, while I<run()> stays the same and only runs Kelp. |
|
74
|
|
|
|
|
|
|
This module replaces those two methods and autoloads the rest of the methods |
|
75
|
|
|
|
|
|
|
from Kelp instance. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 USAGE |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 wrap |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
I<new in 1.10> |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Instead of using I<Kelp::Test::new> use I<KelpX::Symbiosis::Test::wrap> with |
|
84
|
|
|
|
|
|
|
the same interface. Then you can create test cases not only for Kelp routes but |
|
85
|
|
|
|
|
|
|
also for the rest of Plack applications. The I<wrap> method will return a |
|
86
|
|
|
|
|
|
|
L<Kelp::Test> object, so refer to its documentation for more details. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 HOW DOES IT WORK? |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
The main Kelp instance is wrapped in this module class and the resulting object |
|
91
|
|
|
|
|
|
|
is passed into Kelp::Test instead. I<KelpX::Symbiosis::Test> autoloads Kelp |
|
92
|
|
|
|
|
|
|
methods and wraps I<run_all> inside I<run>, which allows L<Kelp::Test> to use |
|
93
|
|
|
|
|
|
|
it. |
|
94
|
|
|
|
|
|
|
|