Skip to content
Browse files

let runtests function accept feature text as args.

  • Loading branch information...
1 parent 6b9cdd6 commit 4cb8cfc0a3acd2d1f890035e5e137383e1f6593e @gugod committed Jun 21, 2009
Showing with 44 additions and 2 deletions.
  1. +3 −0 Changes
  2. +8 −2 lib/Test/Cukes.pm
  3. +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
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 4cb8cfc

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