File: runtests_subset.t

package info (click to toggle)
libtest-spec-perl 0.45-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 252 kB
  • sloc: perl: 2,050; makefile: 2
file content (71 lines) | stat: -rwxr-xr-x 1,905 bytes parent folder | download | duplicates (3)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env perl
#
# runtests_subset.t
#
########################################################################
#

package Testcase::Spec::RuntestsSubset;
use Test::Spec;
use FindBin qw($Bin);
BEGIN { require "$Bin/test_helper.pl" };

describe "Test::Spec" => sub {

  describe "when no specific examples are requested" => sub {
    my $tap;
    before all => sub {
      $tap = capture_tap("subset_spec.pl");
    };
    it "should run all the examples" => sub {
      like $tap, qr/^ok \d+ - Test One.*ok \d+ - Test Two/ms;
    };
  };

  describe "when specific examples are requested explicitly" => sub {
    my $tap;
    before all => sub {
      # case insensitivity is baked in
      $tap = capture_tap("subset_spec.pl", "oNe");
    };
    it "should run the requested examples" => sub {
      like $tap, qr/^ok \d+ - Test One/m;
    };
    it "should run ONLY the requested examples" => sub {
      unlike $tap, qr/^ok \d+ - Test Two/;
    };
  };

  describe "when specific examples are requested via SPEC environment var" => sub {
    my $tap;
    before all => sub {
      # case insensitivity is baked in
      local $ENV{SPEC} = "oNe";
      $tap = capture_tap("subset_spec.pl");
    };
    it "should run the requested examples" => sub {
      like $tap, qr/^ok \d+ - Test One/m;
    };
    it "should run ONLY the requested examples" => sub {
      unlike $tap, qr/^ok \d+ - Test Two/;
    };
  };

  describe "when examples are requested via both SPEC and explicit parameter" => sub {
    my $tap;
    before all => sub {
      # case insensitivity is baked in
      local $ENV{SPEC} = "oNe";
      $tap = capture_tap("subset_spec.pl","tWo");
    };
    it "should run the explicit example" => sub {
      like $tap, qr/^ok \d+ - Test Two/m;
    };
    it "should *not* run the SPEC example" => sub {
      unlike $tap, qr/^ok \d+ - Test One/;
    };
  };

};

runtests unless caller;