Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added prompt tests
  • Loading branch information
kraih committed Oct 15, 2012
1 parent af03414 commit e0d45df
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion t/mojo/bytestream.t
Expand Up @@ -2,7 +2,7 @@ use Mojo::Base -strict;

use utf8;

use Test::More tests => 47;
use Test::More tests => 49;

use File::Spec::Functions qw(catfile splitdir);
use File::Temp 'tempdir';
Expand Down Expand Up @@ -141,6 +141,21 @@ b(1, 2, 3)->say;
*STDOUT = $stdout;
is $buffer, "test\n123\n", 'right output';

# prompt
my $input = "test123\n";
open my $in, '<', \$input;
my $output = '';
open my $out, '>', \$output;
my $stdin = *STDIN;
*STDIN = $in;
$stdout = *STDOUT;
*STDOUT = $out;
$stream = b('Password: ')->prompt;
*STDIN = $stdin;
*STDOUT = $stdout;
is $output, 'Password: ', 'right output';
is $stream, 'test123', 'right input';

# slurp
my $file = catfile splitdir($FindBin::Bin), qw(templates exception.mt);
$stream = b($file)->slurp;
Expand Down

0 comments on commit e0d45df

Please sign in to comment.