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
|
#!perl
use strict;
use warnings;
use Digest;
use Test::More;
use Test::BDD::Cucumber::StepFile;
Given qr/a usable "(\w+)" class/, sub { use_ok( C->matches->[0] ); };
Given qr/a Digest (\S+) object/, sub {
my $object = Digest->new( C->matches->[0] );
ok( $object, "Object created" );
S->{'object'} = $object;
};
When qr/I've added "(.+)" to the object/, sub {
S->{'object'}->add( C->matches->[0] );
};
When "I've added the following to the object", sub {
S->{'object'}->add( C->data );
};
Then qr/the (.+) output is "(.+)"/, sub {
my ( $type, $expected ) = @{ C->matches };
my $method = {
'base64' => 'b64digest',
'hex' => 'hexdigest'
}->{ $type };
is( S->{'object'}->$method, $expected );
};
|