Permalink
Browse files

import Test-Cukes 0.05 from CPAN

git-cpan-module:   Test-Cukes
git-cpan-version:  0.05
git-cpan-authorid: GUGOD
git-cpan-file:     authors/id/G/GU/GUGOD/Test-Cukes-0.05.tar.gz
  • Loading branch information...
1 parent 25125a8 commit 835152119f46d91f28a7ca292f5c7dbc38db0cf0 @gugod committed with schwern Jun 18, 2009
Showing with 14 additions and 5 deletions.
  1. +3 −0 Changes
  2. +1 −1 META.yml
  3. +10 −4 lib/Test/Cukes.pm
View
@@ -1,5 +1,8 @@
# Revision history for Perl extension Test::Cukes
+0.05:
+- Fix the missing step report of "And" steps.
+
0.04:
- report missing steps as TAP note
View
@@ -26,4 +26,4 @@ requires:
Exporter::Lite: 0.02
resources:
license: http://opensource.org/licenses/mit-license.php
-version: 0.04
+version: 0.05
View
@@ -6,7 +6,7 @@ use Test::More;
use Test::Cukes::Feature;
use Carp::Assert;
-our $VERSION = "0.04";
+our $VERSION = "0.05";
our @EXPORT = qw(feature runtests Given When Then assert affirm should shouldnt);
our @missing_steps = ();
@@ -35,15 +35,19 @@ sub runtests {
for my $scenario (@scenarios_of_caller) {
my $skip = 0;
my $skip_reason = "";
-
+ my $gwt;
my %steps = %{$steps->{$caller} ||{}};
SKIP:
for my $step_text (@{$scenario->steps}) {
- my (undef, $step) = split " ", $step_text, 2;
+ my ($pre, $step) = split " ", $step_text, 2;
Test::More::skip($step, 1) if $skip;
+ $gwt = $pre if $pre =~ /(Given|When|Then)/;
+
my $found_step = 0;
- while (my ($step_pattern, $cb) = each %steps) {
+ for my $step_pattern (keys %steps) {
+ my $cb = $steps{$step_pattern};
+
if ($step =~ m/$step_pattern/) {
eval { $cb->(); };
Test::More::ok(!$@, $step_text);
@@ -60,6 +64,7 @@ sub runtests {
}
unless($found_step) {
+ $step_text =~ s/^And /$gwt /;
push @missing_steps, $step_text;
}
}
@@ -71,6 +76,7 @@ sub runtests {
}
sub report_missing_steps {
+ return if @missing_steps == 0;
Test::More::note("There are missing step definitions, fill them in:");
for my $step_text (@missing_steps) {
my ($word, $text) = ($step_text =~ /^(Given|When|Then) (.+)$/);

0 comments on commit 8351521

Please sign in to comment.