File Coverage

blib/lib/Test/Cukes/Scenario.pm
Criterion Covered Total %
statement 16 17 94.1
branch 4 6 66.6
condition 1 3 33.3
subroutine 3 3 100.0
pod 1 1 100.0
total 25 30 83.3


line stmt bran cond sub pod time code
1             package Test::Cukes::Scenario;
2 7     7   71152 use Moose;
  7         471525  
  7         48  
3              
4             has name => (
5             is => "rw",
6             required => 1,
7             isa => "Str"
8             );
9              
10             has steps => (
11             is => "rw",
12             required => 1,
13             isa => "ArrayRef[Str]"
14             );
15              
16             sub BUILDARGS {
17 6     6 1 14 my $class = shift;
18 6 50 33     37 if (@_ == 1 && ! ref $_[0]) {
19 6         15 my $scenario_text = shift;
20 6         23 my $args = {
21             name => "",
22             steps => []
23             };
24              
25 6         49 for my $line (split /\n+/, $scenario_text) {
26 24 100       133 if ($line =~ /^Scenario:\s(.+)$/) {
    50          
27 6         22 $args->{name} = $1;
28             } elsif ($line =~ /^ (Given|When|Then|And)\s(.+)$/) {
29 18         30 push @{$args->{ steps }}, "$1 $2";
  18         73  
30             }
31             }
32              
33 6         182 return $args;
34             }
35              
36 0           return $class->SUPER::BUILDARGS(@_);
37             }
38              
39             __PACKAGE__->meta->make_immutable;
40 7     7   48728 no Moose;
  7         28  
  7         50  
41             1;