App-PRT
view release on metacpan or search on metacpan
t/App-PRT-Collector-Files.t view on Meta::CPAN
sub collect : Tests {
my $directory = t::test::prepare_test_code('hello_world');
subtest 'when files specified' => sub {
my $collector = App::PRT::Collector::Files->new("$directory/hello_world.pl");
is_deeply $collector->collect, ["$directory/hello_world.pl"];
}, 'specified files returned';
subtest 'when not existing file specified' => sub {
my $collector = App::PRT::Collector::Files->new("$directory/not_existd.pl");
ok exception {
$collector->collect;
}, 'died';
};
}
sub collect_multi_files: Tests {
my $directory = t::test::prepare_test_code('dinner');
my $files = [
t/App-PRT-Command-MoveClassMethod.t view on Meta::CPAN
my ($class, $name) = @_;
"Hi, $name\n";
}
1;
CODE
}
sub execute_method_body_when_destination_file_not_exists : Tests {
my $directory = t::test::prepare_test_code('greeting');
my $command = App::PRT::Command::MoveClassMethod->new;
$command->register('Greeting#hi' => 'Salutation#hello');
my $file = "$directory/lib/Greeting.pm";
$command->execute($file);
ok -f $file, 'source file exists';
t/App-PRT-Command-MoveClassMethod.t view on Meta::CPAN
is file($file)->slurp, <<'CODE', 'calling Greeting#hi was rewritten, Hi was added after package statement';
package Main;
use Hi;
print Hi->hello('Alice');
print Greeting->bye('Bob');
CODE
};
}
sub execute_for_not_perl_file: Tests {
my $directory = t::test::prepare_test_code('readme');
my $readme = "$directory/README.md";
my $command = App::PRT::Command::MoveClassMethod->new;
$command->register('Greeting#hi' => 'Hi#hello');
$command->execute($readme);
ok -f $readme, 'README exists';
}
sub parse_arguments : Tests {
t/App-PRT-Command-RenameClass.t view on Meta::CPAN
sub name : Test(1) {
my $food = My::Food->new('banana');
is $food->name, 'banana';
}
__PACKAGE__->runtests;
CODE
}
sub execute_for_not_perl_file: Tests {
my $directory = t::test::prepare_test_code('readme');
my $readme = "$directory/README.md";
my $command = App::PRT::Command::RenameClass->new;
$command->register('Alice' => 'Bob');
$command->execute($readme);
ok -f $readme, 'README exists';
}
sub execute_rename_to_deeper_directory : Tests {
t/App-PRT-Command-ReplaceToken.t view on Meta::CPAN
my $file = "$directory/hello.pl";
$command->execute($file);
is file($file)->slurp, <<'CODE', 'all hello are replaced';
hello('Work');
hello('Work');
hello('Work');
CODE
}
sub execute_for_not_perl_file: Tests {
my $directory = t::test::prepare_test_code('readme');
my $readme = "$directory/README.md";
my $command = App::PRT::Command::ReplaceToken->new;
$command->register('alice' => 'bob');
$command->execute($readme);
ok -f $readme, 'README exists';
}
sub parse_arguments : Tests {
t/App-Prt-Collector-GitDirectory.t view on Meta::CPAN
}
sub instantiate : Tests {
my $directory = t::test::prepare_test_code('hello_world');
ok exception {
App::PRT::Collector::GitDirectory->new;
}, 'directory required';
ok exception {
App::PRT::Collector::GitDirectory->new('not_exist_directory');
}, 'existing directory required';
t::test::prepare_as_git_repository($directory);
subtest 'can initialize with git repository' => sub {
my $collector = App::PRT::Collector::GitDirectory->new($directory);
isa_ok $collector, 'App::PRT::Collector::GitDirectory';
is $collector->directory, $directory, 'collector has directory';
is_deeply $collector->collect, [ "$directory/hello_world.pl" ], 'collector can collect';
};
my $directory = t::test::prepare_test_code('hello_world');
ok $directory;
ok -d $directory, 'directory exists';
ok -f "$directory/hello_world.pl", 'hello_world.pl exists';
};
subtest 'valid input' => sub {
ok exception {
t::test::prepare_test_code('not_defined_name');
}, 'dies when specified code is not prepared'
};
}
sub _prepare_as_git_repository : Tests {
my $directory = t::test::prepare_test_code('hello_world');
t::test::prepare_as_git_repository($directory);
ok -d "$directory/.git", '.git directory exists';
( run in 0.700 second using v1.01-cache-2.11-cpan-cc502c75498 )