lib/Test/BDD/Cucumber/Loader.pm

filter: Statementstmt 97.3% 37 / 38 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 96.3% 53 / 55 CC 5 SCAR 6.8
CC
5
Cov
95%
load_steps
3.2
load
3.0
BEGIN
1.0
CRAP 2.0
« blib/lib/Test/BDD/Cucumber/Harness/TestBuilder.pm ↑ Summary blib/lib/Test/BDD/Cucumber/StepFile.pm »
1 16 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Test::BDD::Cucumber::Loader 0.87;
5  
6 =head1 NAME
7  
8 Test::BDD::Cucumber::Loader - Simplify loading of Step Definition and feature files
9  
10 =head1 VERSION
11  
12 version 0.87
13  
14 =head1 DESCRIPTION
15  
16 Makes loading Step Definition files and Feature files a breeze...
17  
18 =head1 METHODS
19  
20 =head2 load
21  
22 Accepts a path, and returns a L<Test::BDD::Cucumber::Executor> object with the Step
23 Definition files loaded, and a list of L<Test::BDD::Cucumber::Model::Feature> objects.
24  
25 =head2 load_steps
26  
27 Accepts an L<Test::BDD::Cucumber::Executor> object and a string representing either a
28 step file, or a directory containing zero or more C<*_steps.pl> files, and loads
29 the steps in to the executor; if you've used C<load> we'll have already scanned
30 the feature directory for C<*_steps.pl> files.
31  
32 =cut
33  
34  
35 16 ▶use Path::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 16 ▶use File::Find::Rule;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 16 ▶use Test::BDD::Cucumber::Executor;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 16 ▶use Test::BDD::Cucumber::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 16 ▶use Test::BDD::Cucumber::StepFile();
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 21 ▶sub load {
Subroutine load: called CC=3 SCAR=11.0
Pod documented
43 21 my ( $class, $path ) = @_;
44  
45 21 my $executor = Test::BDD::Cucumber::Executor->new();
46  
47 # Either load a feature or a directory...
48 21 my ( $dir, $file );
49 21 ▶ if ( -f $path ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $path) { } 4 17 21
50 4 $file = file($path);
51 4 $dir = $file->dir;
52 } else {
53 17 $dir = dir($path);
54 }
55  
56 # Load up the steps
57 21 $class->load_steps( $executor, $dir );
58  
59 # Grab the feature files
60 my @features = map {
61 21 my $file = file($_);
62 26 ▶ my $feature =
Branch: 1 branch
BranchTrueFalseTotal
$file ? : 4 17 21
63 Test::BDD::Cucumber::Parser->parse_file( $file );
64 } (
65 $file
66 ? ( $file . '' )
67 : File::Find::Rule->file()->name('*.feature')->in($dir)
68 );
69  
70 21 return ( $executor, @features );
71 }
72  
73 21 ▶sub load_steps {
Subroutine load_steps: called CC=3 SCAR=11.7
Pod documented
74 21 my ( $class, $executor, $path ) = @_;
75  
76 21 ▶ if ( -f $path ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $path) { } 0 21 21
77 0 $executor->add_steps( Test::BDD::Cucumber::StepFile->load($path) );
78 } else {
79 $executor->add_steps( Test::BDD::Cucumber::StepFile->load($_) )
80 21 for File::Find::Rule->file()->name('*_steps.pl')->in($path);
81 }
82  
83 21 return $class;
84 }
85  
86 =head1 AUTHOR
87  
88 Peter Sergeant C<pete@clueball.com>
89  
90 =head1 LICENSE
91  
92 Copyright 2019-2023, Erik Huelsmann
93 Copyright 2011-2019, Peter Sergeant; Licensed under the same terms as Perl
94  
95 =cut
96  
97 16 1;
« blib/lib/Test/BDD/Cucumber/Harness/TestBuilder.pm ↑ Summary blib/lib/Test/BDD/Cucumber/StepFile.pm »