Permalink
Browse files

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...
1 parent 8351521 commit 4ed472427b1a223c5018c9258ee519561e13f7e3 @gugod committed with schwern Jun 21, 2009
Showing with 46 additions and 3 deletions.
  1. +3 −0 Changes
  2. +1 −0 MANIFEST
  3. +1 −1 META.yml
  4. +8 −2 lib/Test/Cukes.pm
  5. +33 −0 t/runtest-with-arg.t
View
3 Changes
@@ -1,5 +1,8 @@
# Revision history for Perl extension Test::Cukes
+0.06:
+- let runtests accept feature text too
+
0.05:
- Fix the missing step report of "And" steps.
View
1 MANIFEST
@@ -20,6 +20,7 @@ META.yml
README
t/00_compile.t
t/feature.t
+t/runtest-with-arg.t
t/runtest-without-defined-steps.t
t/runtest.t
t/scenario.t
View
2 META.yml
@@ -26,4 +26,4 @@ requires:
Exporter::Lite: 0.02
resources:
license: http://opensource.org/licenses/mit-license.php
-version: 0.05
+version: 0.06
View
10 lib/Test/Cukes.pm
@@ -6,7 +6,7 @@ use Test::More;
use Test::Cukes::Feature;
use Carp::Assert;
-our $VERSION = "0.05";
+our $VERSION = "0.06";
our @EXPORT = qw(feature runtests Given When Then assert affirm should shouldnt);
our @missing_steps = ();
@@ -23,6 +23,12 @@ sub feature {
sub runtests {
my $caller = caller;
+ my $feature_text = shift;
+
+ if ($feature_text) {
+ $feature->{$caller} = Test::Cukes::Feature->new($feature_text);
+ }
+
my $total_tests = 0;
my @scenarios_of_caller = @{$feature->{$caller}->scenarios};
@@ -80,7 +86,7 @@ sub report_missing_steps {
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) (.+)$/);
- my $msg = "\n$word qr/${text}/ => sub {\n ...\n}\n";
+ my $msg = "\n$word qr/${text}/ => sub {\n ...\n};\n";
Test::More::note($msg);
}
}
View
33 t/runtest-with-arg.t
@@ -0,0 +1,33 @@
+#!/usr/bin/env perl -w
+use strict;
+use Test::Cukes;
+my @passed;
+
+Given qr/blah1/ => sub {
+ push @passed, 1;
+
+ assert @passed == 1;
+};
+
+When qr/blah2/ => sub {
+ push @passed, 2;
+ assert @passed == 2;
+};
+
+Then qr/blah3/ => sub {
+ push @passed, 3;
+ assert @passed == 3;
+
+ assert( @{[ 1, 2, 3 ]} == @passed );
+};
+
+runtests(<<FEATURE_TEXT);
+Feature: foo
+ In order to bleh
+ I want to bleh
+
+ Scenario: blehbleh
+ Given blah1
+ When blah2
+ Then blah3
+FEATURE_TEXT

0 comments on commit 4ed4724

Please sign in to comment.