BDD Demo



examples/bdd/demo/features/basic.feature
Feature: Show the features of Test::BDD::Cucumber
   Run "prove -v  -r --source Feature --ext=.feature ."
   Run pherkin .
   (free text)

Background:
   Given a Fixture called Blue


Scenario: First scenario
    Longer explanation of the scenario (free text)
  Given a Green object
  When I've added "alpha" to the object
  And I've added "beta" to the object
  Then the output is "blabla"
  Then the error is ""


Scenario: Second scenario
    Longer explanation of the scenario (free text)
  Given a Yellow object
  When I've added "gamma" to the object
  And I've added "delta" to the object
  Then the output is "blabla"
  Then the error is "bad, really bad"

examples/bdd/demo/features/step_definitions/some_steps.pl
#!perl

use strict;
use warnings;

use Test2::Bundle::More;
use Test::BDD::Cucumber::StepFile;


Given qr/a Fixture called (\S+)/, sub {
    my $name = $1;
    diag "The fixture is $name";
    ok 1, "OK $name";   # really $1 as in the tutorial?
};

Given qr/a (\S+) object/, sub {
    my $name = C->matches->[0];
    ok 1, "OK $name";
};

When qr/I've added "(.+)" to the object/, sub {
    push @{ S->{'object'} }, C->matches->[0];
};


Before sub {
    diag 'before';
};

After sub {
    my $c = shift;

    diag 'after'
    # $c->stash->{'scenario'}->{'Calculator'};
};

Then qr/^the output is "(.+)"/, sub {
    my ($value) = @{ C->matches };
    ok 1, "expected output is $value";
};

Then qr/^the error is "(.*)"/, sub {
    my ($value) = @{ C->matches };
    ok 1, "expected error is $value";
    #is "expected", "recived", "demo";
};


# Transform qr/^(__THE_NUMBER_\w+__)$/, sub { map_word_to_number($1) };
# Transform qr/^table:number as word$/, sub {

# S->{'object'}->add( C->data );
#