File: App-PRT-Command-IntroduceVariables.t

package info (click to toggle)
prt 0.22-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 404 kB
  • sloc: perl: 1,185; makefile: 3
file content (50 lines) | stat: -rw-r--r-- 1,200 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
package t::App::PRT::Command::IntroduceVariables;
use t::test;

sub _require : Test(startup => 1) {
    my ($self) = @_;

    use_ok 'App::PRT::Command::IntroduceVariables';
}

sub instantiate : Tests {
    isa_ok App::PRT::Command::IntroduceVariables->new, 'App::PRT::Command::IntroduceVariables';
}

sub collect_variables : Tests {
    my $directory = t::test::prepare_test_code('dinner');
    my $food_file = "$directory/lib/My/Food.pm";

    my $command = App::PRT::Command::IntroduceVariables->new;

    is_deeply $command->collect_variables($food_file), [
        '$My::Food::SOME_MAGIC_NUMBER',
        '$My::Food::Foo::GLOBAL_VAR',
        '$class',
        '$name',
        '@_',
        '$self',
    ];
}

sub execute : Tests {
    my $directory = t::test::prepare_test_code('dinner');
    my $food_file = "$directory/lib/My/Food.pm";

    my $command = App::PRT::Command::IntroduceVariables->new;
    my $out_file = file("$directory/out.txt");
    my $out_fh = $out_file->openw;

    $command->execute($food_file, $out_fh);

    close $out_fh;
    is $out_file->slurp, <<'CODE', 'variables introduces';
$My::Food::SOME_MAGIC_NUMBER
$My::Food::Foo::GLOBAL_VAR
$class
$name
@_
$self
CODE

}