File Coverage

blib/lib/Test/Cukes/Feature.pm
Criterion Covered Total %
statement 23 26 88.4
branch 3 6 50.0
condition 1 3 33.3
subroutine 4 4 100.0
pod 1 1 100.0
total 32 40 80.0


line stmt bran cond sub pod time code
1             package Test::Cukes::Feature;
2 6     6   62972 use Any::Moose;
  6         1278494  
  6         43  
3              
4 6     6   11569 use Test::Cukes::Scenario;
  6         16  
  6         2064  
5              
6             has name => (
7             is => "rw",
8             required => 1,
9             isa => "Str"
10             );
11              
12             has body => (
13             is => "rw",
14             isa => "Str"
15             );
16              
17             has scenarios => (
18             is => "rw",
19             isa => "ArrayRef[Test::Cukes::Scenario]"
20             );
21              
22             sub BUILDARGS {
23 5     5 1 530 my $class = shift;
24 5 50 33     89 if (@_ == 1 && ! ref $_[0]) {
25 5         12 my $text = shift;
26 5         24 my $args = {
27             name => "",
28             body => "",
29             scenarios => []
30             };
31 5         92 my @blocks = split /\n\n/, $text;
32 5         12 my $meta = shift @blocks;
33              
34 5 50       56 unless ($meta =~ m/^Feature:\s([^\n]+x?)$(.+)\z/sm) {
35 0         0 die "Cannot extra feature name and body from text:\n----\n$meta\n----\n\n";
36             }
37              
38 5         23 $args->{name} = $1;
39 5         24 $args->{body} = $2;
40              
41 5         20 for my $scenario_text (@blocks) {
42 5 50       94 unless ($scenario_text =~ s/^ (.+?)$/$1/mg) {
43 0         0 die "Scenario text is not properly indented:\n----\n${scenario_text}\n----\n\n";
44             }
45 5         9 push @{$args->{scenarios}}, Test::Cukes::Scenario->new($scenario_text)
  5         60  
46             }
47              
48 5         198 return $args;
49             }
50              
51 0           return $class->SUPER::BUILDARGS(@_);
52             }
53              
54             __PACKAGE__->meta->make_immutable;
55 6     6   41 no Any::Moose;
  6         13  
  6         30  
56             1;