Андрей Тутукин > Test-Pcuke > Test::Pcuke::StepDefinition

Download:
Test-Pcuke-0.000006.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Source  

NAME ^

Test::Pcuke::StepDefinition - Provides the commands for steps' definitions

SYNOPSIS ^

This module is used to define steps. If you are pcuke user then you probably want save your step definitions to <your project>/features/step_definitions/steps.pm. Content of that file could look like this:

        package steps;
        use utf8;               # for i18n-zed regexps
        use warnings;
        use strict;
        
        use Test::Pcuke::StepDefinition;
        
        Given qr{^a calculator instance$} => sub {
        my ($world, $text, $table) = @_;
        $world->{_calculator} = Local::Adder->new;
        };
        
        Given qr{^I have entered "([^"]+)" into the calculator} => sub {
                my ($world, $text, $table) = @_;
                push @{ $world->{_arguments} }, $1;
        };

        When qr{^I press "([^"]+)"$} => sub {
                my ($world, $text, $table) = @_;
                my ($a1, $a2) = @{ $world->{_arguments} };
                $world->{_result} = $world->{_calculator}->add( $a1, $a2 );
        };

        Then qr{^the result should be "([^"]+)" on the screen$} => sub {
                my ($world, $text, $table) = @_;
                expect( $world->{_result} )->equals($1);
        };
        
        1; # Do not forget this number. pcuke uses require

Note that if you can use native language in *.feature file you can't currently use native language for Given, When etc.

EXPORT ^

Given, When, Then, And, But

SUBROUTINES ^

Given $regexp $coderef

Synonym of the add_step.

When $regexp $coderef

Synonym of the add_step.

Then $regexp $coderef

Synonym of the add_step.

And $regexp $coderef

Synonym of the add_step.

But $regexp $coderef

Synonym of the add_step.

add_step $regexp, $coderef

Add a definition for a step whose title match $regexp.

See Test::Pcuke::Executor->add_definition().

expect $object

Return Test::Pcuke::Expectation object. Use it for tests in step definitions

AUTHOR ^

Andrei V. Toutoukine, <tut at isuct.ru>

BUGS ^

Please report any bugs or feature requests to bug-test-pcuke at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Pcuke. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc Test::Pcuke::StepDefinition

You can also look for information at:

ACKNOWLEDGEMENTS ^

LICENSE AND COPYRIGHT ^

Copyright 2011 Andrei V. Toutoukine.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

syntax highlighting: