File: runtest.t

package info (click to toggle)
libtest-cukes-perl 0.09-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 200 kB
  • ctags: 155
  • sloc: perl: 1,959; makefile: 2
file content (50 lines) | stat: -rw-r--r-- 1,069 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env perl -w
use strict;
use Test::Cukes;
use Test::More;

feature(<<FEATURE_TEXT);
Feature: foo
  In order to bleh
  I want to bleh

  Scenario: blehbleh
    Given I will say the word 'cake'
    When it is my birthday
    Then we will eat 28 cakes
FEATURE_TEXT

my @passed;
my @regex_matches;

Given qr/I will say the word '(.+)'/ => sub {
    push @passed, 1;
    push @regex_matches, @_;

    assert @passed        == 1;
    assert @regex_matches == 1
};

When qr/it is my birthday/ => sub {
    push @passed, 2;

    ok 1, "Using is, ok, etc no longer screw up Cuke's test plan and cause"
      . " it to fail.";

    assert @passed        == 2;
    assert @regex_matches == 1
};

Then qr/we will eat (\d+) (.+)/ => sub {
    push @passed, 3;
    push @regex_matches, @_;

    assert @passed        == 3;
    assert @regex_matches == 3;

    is_deeply [1, 2, 3], \@passed, "Steps were called in the correct order";
    is_deeply ['cake', 28, 'cakes'], \@regex_matches, "Regex matches were"
      . " correctly passed to the step functions";
};

runtests;