NAME

Test::BDD::Infrastructure::Utils - class with collection of some utility functions

VERSION

version 1.005

Human readable operators

The Utils package provides human readable comparsion operators.

convert_cmp_operator( $op )

Returns the perl operator for $op as string.

$CMP_OPERATOR_RE

Contains a regex to match all supported operators.

Synopsis

use Test::BDD::Infrastructure::Utils qw(
      convert_cmp_operator $CMP_OPERATOR_RE );

Then qr/the file must contain $CMP_OPERATOR_RE (\d+) lines/, sub {
  my $op = convert_cmp_operator( $1 );
  my $count = $2;
  my $lines = calc_lines();
  cmp_ok( $lines, $op, $count, "the file must contain $op $count lines");
}

Examples

Then the file must contain at least 10 lines

Supported Operators

at least
a maximum of
not more than
more than
bigger than
greater than
less than
smaller than
equal
exactly
newer than
older than

Byte units

The module provides conversion of human readable byte units.

convert_unit( $size, $unit )

Returns the size in bytes.

Supported units

percent, %

1/100

byte, b

1 byte

kilobyte, kb

1000 byte

megabyte, mb

1000000 byte

gigabyte, gb

1000000000 byte

terrabyte, tb

1000000000000 byte

kibibyte, kib

1024 byte

mebibyte, mib

1048576 byte

gibibyte, gib

1073741824 byte

tebibyte, tb

1099511627776 byte

Intervals

The module provides conversion of human readable intervals.

convert_interval( $count, $unit )

Return the interval in seconds.

Supported intervals

second(s)
day(s)
week(s)
hour(s)
minute(s)
month(s)
year(s)

Configuration variables

A backend for retrieving configuration variables is implemented in Test::BDD::Infrastrucuture::Config.

The following short-cut methods could be used to implement configuration variables in step file definitions.

The syntax for variables is $<path> or $<scope>:<path>

If the scope is omitted the default 'c' will be used.

Example usage

If the step file definition is:

Then qr/the value (\S+) must be bla/, sub {
  my $value = lookup_config( $1 );
  ok( is_bla($value), 'value must be bla' );
}

then it could be used with variables:

Then the value $bla must be bla

lookup_config( $str )

Tries to lookup the configuration value for $str if $str starts with "$" otherwise the string is returned as-is.

lookup_config_node( $str )

Tries to lookup the configuration node for $str otherwise undef is returned.

AUTHOR

Markus Benning <ich@markusbenning.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Markus Benning.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.