[libtest-bdd-cucumber-perl] 13/25: Load harness class inside _process_arguments in App::pherkin
Intrigeri
intrigeri at moszumanska.debian.org
Mon Apr 27 09:51:16 UTC 2015
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to branch master
in repository libtest-bdd-cucumber-perl.
commit 8ecac62d2f074d9390ca898a24b9f09ccd456280
Author: Tomas Pokorny <tnt at verotel.cz>
Date: Mon Apr 13 12:49:13 2015 +0000
Load harness class inside _process_arguments in App::pherkin
so that harness is also loaded into object attribute
same way as other command-line options.
---
lib/App/pherkin.pm | 20 ++++++++++----------
t/400_app_pherkin_harnesses.t | 3 ++-
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/lib/App/pherkin.pm b/lib/App/pherkin.pm
index 90fe2f8..98c4c92 100644
--- a/lib/App/pherkin.pm
+++ b/lib/App/pherkin.pm
@@ -17,6 +17,8 @@ use Moose;
has 'tags' => ( is => 'rw', isa => 'ArrayRef', required => 0 );
has 'tag_scheme' => ( is => 'rw', isa => 'ArrayRef', required => 0 );
+has 'harness' => ( is => 'rw' );
+
=head1 NAME
App::pherkin - Run Cucumber tests from the command line
@@ -55,14 +57,15 @@ sub run {
# localized features will have utf8 in them and options may output utf8 as well
binmode STDOUT, ':utf8';
- my ( $options, @feature_files ) = $self->_process_arguments(@arguments);
+ my ( $features_path ) = $self->_process_arguments(@arguments);
+ $features_path ||= './features/';
- my $features_path = $feature_files[0] || './features/';
my ( $executor, @features ) =
Test::BDD::Cucumber::Loader->load( $features_path, $self->tag_scheme );
die "No feature files found in $features_path" unless @features;
- my $harness = $self->_load_harness( $options->{'harness'} );
+ my $harness = $self->harness;
+ $harness->startup();
my $tag_spec;
if ( $self->tag_scheme ) {
@@ -76,7 +79,7 @@ sub run {
return $harness->result;
}
-sub _load_harness {
+sub _initialize_harness {
my ( $self, $harness_module ) = @_;
unless ( $harness_module =~ m/::/ ) {
@@ -86,10 +89,7 @@ sub _load_harness {
eval { use_module($harness_module) }
|| die "Unable to load harness [$harness_module]: $@";
- my $harness = $harness_module->new();
- $harness->startup();
-
- return $harness;
+ $self->harness( $harness_module->new() );
}
sub _process_arguments {
@@ -126,14 +126,14 @@ sub _process_arguments {
unshift @$includes, 'blib/lib', 'blib/arch' if $add_blib;
# Munge the output harness
- $harness = "TermColor" unless defined $harness;
+ $self->_initialize_harness($harness || "TermColor");
lib->import(@$includes) if @$includes;
# Store our TagSpecScheme
$self->tag_scheme( $self->_process_tags( @{$tags} ) );
- return ( { harness => $harness }, pop @ARGV );
+ return ( pop @ARGV );
}
sub _process_tags {
diff --git a/t/400_app_pherkin_harnesses.t b/t/400_app_pherkin_harnesses.t
index 3e17ee3..18d6e9b 100644
--- a/t/400_app_pherkin_harnesses.t
+++ b/t/400_app_pherkin_harnesses.t
@@ -16,12 +16,13 @@ use_ok("App::pherkin");
for my $harness (@known_harnesses) {
my $app = App::pherkin->new();
- my $object = $app->_load_harness($harness);
+ my $object = $app->_initialize_harness($harness);
isa_ok(
$object,
"Test::BDD::Cucumber::Harness",
"Loaded harness by name: [$harness] -> [" . ( ref $object ) . "]"
);
+ is($app->harness, $object, "It is set to app->harness [$harness]");
}
done_testing();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libtest-bdd-cucumber-perl.git
More information about the Pkg-perl-cvs-commits
mailing list