File Coverage

blib/lib/Story/Interact/Harness/Test.pm
Criterion Covered Total %
statement 32 35 91.4
branch 3 4 75.0
condition n/a
subroutine 10 11 90.9
pod 0 5 0.0
total 45 55 81.8


line stmt bran cond sub pod time code
1 4     4   2037 use 5.010001;
  4         20  
2 4     4   26 use strict;
  4         16  
  4         102  
3 4     4   21 use warnings;
  4         10  
  4         303  
4              
5             package Story::Interact::Harness::Test;
6              
7             our $AUTHORITY = 'cpan:TOBYINK';
8             our $VERSION = '0.001013';
9              
10 4     4   57 use Moo;
  4         14  
  4         33  
11 4     4   1379 use Types::Common -types;
  4         10  
  4         29  
12 4     4   57056 use namespace::clean;
  4         10  
  4         32  
13              
14             with 'Story::Interact::Harness';
15              
16             has page => (
17             is => 'rwp',
18             isa => Object,
19             );
20              
21             sub BUILD {
22 9     9 0 742 my ( $self, $args ) = @_;
23 9         52 my $page = $self->get_page( 'main' ); # hard code for testing
24 9         177 $self->_set_page( $page );
25             }
26              
27             sub page_text {
28 17     17 0 90 my ( $self ) = @_;
29 17         30 join qq{\n\n}, @{ $self->page->text };
  17         239  
30             }
31              
32             sub page_location {
33 0     0 0 0 my ( $self ) = @_;
34 0         0 $self->page->location;
35             }
36              
37             sub has_next_page {
38 36     36 0 65 my ( $self, $regexp ) = @_;
39 36         54 for my $next_page ( @{ $self->page->next_pages } ) {
  36         135  
40 43 100       361 return $next_page if $next_page->[1] =~ $regexp;
41             }
42 0         0 return 0;
43             }
44              
45             sub go {
46 36     36 0 2203 my ( $self, $regexp ) = @_;
47 36 50       89 my $next_page = $self->has_next_page( $regexp ) or return 0;
48 36         175 my $page = $self->get_page( $next_page->[0] );
49 36         662 $self->_set_page( $page );
50 36         1089 return 1;
51             }
52              
53             1;