File: 230_tag_matching.t

package info (click to toggle)
libtest-bdd-cucumber-perl 0.26-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 528 kB
  • sloc: perl: 3,436; makefile: 8
file content (52 lines) | stat: -rw-r--r-- 1,275 bytes parent folder | download | duplicates (2)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!perl

use strict;
use warnings;

use Test::More;
use Test::BDD::Cucumber::Model::Scenario;
use Test::BDD::Cucumber::Model::TagSpec;

my @scenarios = map {
	my @atoms = @$_;
	Test::BDD::Cucumber::Model::Scenario->new({
		name => shift(@atoms),
		tags => \@atoms
	});
} (
	[ mercury => qw/all inner / ],
	[ venus   => qw/all inner / ],
	[ earth   => qw/all inner life home/ ],
	[ mars    => qw/all inner life red / ],
	[ jupiter => qw/all outer gas red / ],
	[ saturn  => qw/all outer gas/ ],
	[ uranus  => qw/all outer gas/ ],
	[ nepture => qw/all outer gas/ ],
	[ pluto   => qw/all outer fake/ ],
);

for my $test (
	[
		"Lifers and Fakers",
		[ or => 'life', 'fake' ], qw/ earth mars pluto /,
	],
	[
		"Lifeless inner",
		[ and => [ not => 'life' ], 'inner' ], qw/ mercury venus /,
	],
	[
		"Home or Red, Inner",
		[ and => 'inner', [ or => 'home', 'red' ] ], qw/ earth mars /,
	],
	[
		"Home or Not Red, Inner",
		[ and => 'inner', [ or => 'home', [ not => 'red' ] ] ], qw/ mercury venus earth /,
	]
) {
	my ( $name, $search, @result ) = @$test;
	my $tag_spec = Test::BDD::Cucumber::Model::TagSpec->new({ tags => $search });
	my @matches = map { $_->name } $tag_spec->filter( @scenarios );
	is_deeply( \@matches, \@result, "Matched scenario: $name" );
}

done_testing();