line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
$KelpX::Symbiosis::Test::VERSION = '1.14'; |
2
|
|
|
|
|
|
|
use Kelp::Base; |
3
|
6
|
|
|
6
|
|
620635
|
use Kelp::Test; |
|
6
|
|
|
|
|
72996
|
|
|
6
|
|
|
|
|
37
|
|
4
|
6
|
|
|
6
|
|
3038
|
|
|
6
|
|
|
|
|
222064
|
|
|
6
|
|
|
|
|
34
|
|
5
|
|
|
|
|
|
|
attr "-app" => sub { die "`app` parameter is required" }; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
{ |
8
|
|
|
|
|
|
|
my ($class, %args) = @_; |
9
|
|
|
|
|
|
|
my $self = $class->new(%args); |
10
|
5
|
|
|
5
|
1
|
4325
|
return Kelp::Test->new(app => $self); |
11
|
5
|
|
|
|
|
33
|
} |
12
|
5
|
|
|
|
|
46
|
|
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
shift->app->run_all(@_); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
19
|
|
|
19
|
0
|
57258
|
{ |
18
|
|
|
|
|
|
|
my ($self, $func) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
if (ref $self) { |
21
|
|
|
|
|
|
|
my $can = $self->app->can($func); |
22
|
14
|
|
|
14
|
0
|
26059
|
return $can if defined $can; |
23
|
|
|
|
|
|
|
} |
24
|
14
|
100
|
|
|
|
39
|
|
25
|
2
|
|
|
|
|
4
|
return $self->SUPER::can($func); |
26
|
2
|
50
|
|
|
|
17
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
{ |
29
|
12
|
|
|
|
|
78
|
my ($self) = shift; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $func = our $AUTOLOAD; |
32
|
|
|
|
|
|
|
return if $func =~ /::DESTROY$/; |
33
|
|
|
|
|
|
|
$func =~ s/.*:://; |
34
|
21
|
|
|
21
|
|
287847
|
|
35
|
|
|
|
|
|
|
my $method = $self->app->can($func); |
36
|
21
|
|
|
|
|
43
|
die "Kelp cannot $func" unless $method; |
37
|
21
|
100
|
|
|
|
275
|
$method->($self->app, @_); |
38
|
15
|
|
|
|
|
80
|
} |
39
|
|
|
|
|
|
|
|
40
|
15
|
|
|
|
|
52
|
1; |
41
|
15
|
50
|
|
|
|
117
|
|
42
|
15
|
|
|
|
|
35
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
KelpX::Symbiosis::Test - Allow testing symbiotic environments using Kelp::Test |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# in test file |
49
|
|
|
|
|
|
|
use KelpX::Symbiosis::Test; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $t = KelpX::Symbiosis::Test->wrap(app => $kelp_app); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# continue testing using $t, just like Kelp::Test |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This module allows testing Kelp apps with Symbiosis using L<Kelp::Test>. The problem with I<Kelp::Test> is that it automatically runs I<run()> on the app without any way to configure this behavior. Symbiotic apps use I<run_all()> to run the whole environment, while I<run()> stays the same and only runs Kelp. This module replaces those two methods and autoloads the rest of the methods from Kelp instance. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 USAGE |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 wrap |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
I<new in 1.10> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Instead of using I<Kelp::Test::new> use I<KelpX::Symbiosis::Test::wrap> with the same interface. Then you can create test cases not only for Kelp routes but also for the rest of Plack applications. The I<wrap> method will return a L<Kelp::Test> object, so refer to its documentation for more details. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 HOW DOES IT WORK? |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
The main Kelp instance is wrapped in this module class and the resulting object is passed into Kelp::Test instead. I<KelpX::Symbiosis::Test> autoloads Kelp methods and wraps I<run_all> inside I<run>, which allows L<Kelp::Test> to use it. |
70
|
|
|
|
|
|
|
|