BDD Hello World



examples/bdd/
└── basic
    ├── features
    │   ├── basic.feature
    │   └── step_definitions
    │       └── some_steps.pl
    └── lib
        └── HelloWorld.pm


examples/bdd/basic/features/basic.feature
Feature: Hello World

  Scenario: Hello World
    Given the HelloWorld module
    When calling hello_world function
    Then return is "Hello World!"

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

use strict;
use warnings;

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

use lib 'examples/basic/lib/';
use HelloWorld;

Given 'the HelloWorld module', sub {
};

When qr/^calling hello_world function/, sub {
    S->{'result'}  = HelloWorld::hello_world();
};

Then qr/return is "(.+)"/, sub {
    my $expected = C->matches->[0];
    is S->{'result'}, $expected;
};

examples/bdd/basic/lib/HelloWorld.pm
package HelloWorld;
use strict;
use warnings;

sub hello_world {
    return 'Hello World!'
}

1;

pherkin examples/bdd/basic/
prove -v  -r --source Feature --ext=.feature examples/bdd/basic/