Skip to content

Commit

Permalink
split apart app.t
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Axel 'fREW' Schmidt committed Aug 10, 2012
1 parent 6bd4104 commit 2bb72e6
Show file tree
Hide file tree
Showing 6 changed files with 292 additions and 232 deletions.
232 changes: 0 additions & 232 deletions t/app.t

This file was deleted.

98 changes: 98 additions & 0 deletions t/integration/app/drink.t
@@ -0,0 +1,98 @@
#!/usr/bin/env perl

use 5.14.1;
use warnings;

use Test::More;
use App::Cmd::Tester;

use lib 't/lib';

use A 'stdout_is';

my $app = A->app;

local $ENV{PATH} = 't/editors:' . $ENV{PATH};

subtest 'ls' => sub {
my $result = test_app($app => [qw(drink ls)]);
stdout_is($result, [
'* Tom Collins',
'* Cuba Libre',
'* Frewba Libre',
]);
};

subtest 'new' => sub {
local $ENV{EDITOR} = 'drink-new-1';
my $result = test_app($app => [qw(drink new frew)]);
stdout_is($result, [
'## Awesome bevvy',
'',
'## Ingredients',
'',
' * 4 ounces of ice',
'',
'## Description',
'',
"YUMM",
'',
q(Source: Boy's Life),
'',
'',
'drink (Awesome bevvy) created',
]);
};

subtest 'new --based_on' => sub {
local $ENV{EDITOR} = 'drink-new-based-on';
my $result = test_app($app => [qw(drink new --based_on), 'Awesome bevvy']);
stdout_is($result, [
'## silly new name',
'',
'## Ingredients',
'',
' * 4 ounces of ice',
'',
'## Description',
'',
"YUMM",
'',
q(Variant of Awesome bevvy),
'',
q(Source: Boy's Life),
'',
'',
'drink (silly new name) created',
]);
};

subtest 'rm' => sub {
my $result = test_app($app => [qw(drink rm), 'tom*']);
stdout_is($result, ["drink (Tom Collins) deleted"], 'simple deletion works');
};

subtest 'edit' => sub {
local $ENV{EDITOR} = 'drink-edit-1';
my $result = test_app($app => [qw(drink edit), 'frewba libre']);
stdout_is($result, [
'## Frewba Libre',
'',
'## Ingredients',
'',
'',
'## Description',
'',
"A Delicious beverage of frew's own design",
'',
'Variant of Cuba Libre',
'',
'Source: TV Guide wtf?',
'',
'',
'drink (Frewba Libre) updated',
]);
};

done_testing;

34 changes: 34 additions & 0 deletions t/integration/app/help.t
@@ -0,0 +1,34 @@
#!/usr/bin/env perl

use 5.14.1;
use warnings;

use Test::More;
use App::Cmd::Tester;

use lib 't/lib';

use A 'stdout_is';

my $app = A->app;

local $ENV{PATH} = 't/editors:' . $ENV{PATH};

local $TODO = q(App::Cmd can't test help for subcommands?);
my $result = test_app($app => [qw(drink help)]);
stdout_is($result, [
'app.t <command>',
'',
'Available commands:',
'',
q( commands: list the application's commands),
q( help: display a command's help screen),
'',
' drink: interact with drinks',
'ingredient: interact with ingredients',
' inventory: interact with inventory',
' maint: ',
'',
]);

done_testing;

0 comments on commit 2bb72e6

Please sign in to comment.