Skip to content
This repository
Browse code

import Test-Cukes 0.06 from CPAN

git-cpan-module:   Test-Cukes
git-cpan-version:  0.06
git-cpan-authorid: GUGOD
git-cpan-file:     authors/id/G/GU/GUGOD/Test-Cukes-0.06.tar.gz
  • Loading branch information...
commit 4ed472427b1a223c5018c9258ee519561e13f7e3 1 parent 8351521
Kang-min Liu authored schwern committed
3  Changes
... ... @@ -1,5 +1,8 @@
1 1 # Revision history for Perl extension Test::Cukes
2 2
  3 +0.06:
  4 +- let runtests accept feature text too
  5 +
3 6 0.05:
4 7 - Fix the missing step report of "And" steps.
5 8
1  MANIFEST
@@ -20,6 +20,7 @@ META.yml
20 20 README
21 21 t/00_compile.t
22 22 t/feature.t
  23 +t/runtest-with-arg.t
23 24 t/runtest-without-defined-steps.t
24 25 t/runtest.t
25 26 t/scenario.t
2  META.yml
@@ -26,4 +26,4 @@ requires:
26 26 Exporter::Lite: 0.02
27 27 resources:
28 28 license: http://opensource.org/licenses/mit-license.php
29   -version: 0.05
  29 +version: 0.06
10 lib/Test/Cukes.pm
@@ -6,7 +6,7 @@ use Test::More;
6 6 use Test::Cukes::Feature;
7 7 use Carp::Assert;
8 8
9   -our $VERSION = "0.05";
  9 +our $VERSION = "0.06";
10 10 our @EXPORT = qw(feature runtests Given When Then assert affirm should shouldnt);
11 11
12 12 our @missing_steps = ();
@@ -23,6 +23,12 @@ sub feature {
23 23
24 24 sub runtests {
25 25 my $caller = caller;
  26 + my $feature_text = shift;
  27 +
  28 + if ($feature_text) {
  29 + $feature->{$caller} = Test::Cukes::Feature->new($feature_text);
  30 + }
  31 +
26 32 my $total_tests = 0;
27 33 my @scenarios_of_caller = @{$feature->{$caller}->scenarios};
28 34
@@ -80,7 +86,7 @@ sub report_missing_steps {
80 86 Test::More::note("There are missing step definitions, fill them in:");
81 87 for my $step_text (@missing_steps) {
82 88 my ($word, $text) = ($step_text =~ /^(Given|When|Then) (.+)$/);
83   - my $msg = "\n$word qr/${text}/ => sub {\n ...\n}\n";
  89 + my $msg = "\n$word qr/${text}/ => sub {\n ...\n};\n";
84 90 Test::More::note($msg);
85 91 }
86 92 }
33 t/runtest-with-arg.t
... ... @@ -0,0 +1,33 @@
  1 +#!/usr/bin/env perl -w
  2 +use strict;
  3 +use Test::Cukes;
  4 +my @passed;
  5 +
  6 +Given qr/blah1/ => sub {
  7 + push @passed, 1;
  8 +
  9 + assert @passed == 1;
  10 +};
  11 +
  12 +When qr/blah2/ => sub {
  13 + push @passed, 2;
  14 + assert @passed == 2;
  15 +};
  16 +
  17 +Then qr/blah3/ => sub {
  18 + push @passed, 3;
  19 + assert @passed == 3;
  20 +
  21 + assert( @{[ 1, 2, 3 ]} == @passed );
  22 +};
  23 +
  24 +runtests(<<FEATURE_TEXT);
  25 +Feature: foo
  26 + In order to bleh
  27 + I want to bleh
  28 +
  29 + Scenario: blehbleh
  30 + Given blah1
  31 + When blah2
  32 + Then blah3
  33 +FEATURE_TEXT

0 comments on commit 4ed4724

Please sign in to comment.
Something went wrong with that request. Please try again.