Skip to content

Commit

Permalink
show usage
Browse files Browse the repository at this point in the history
  • Loading branch information
xaicron committed Jul 10, 2011
1 parent fc1b65b commit 86777e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/App/envfile.pm
Expand Up @@ -19,6 +19,7 @@ sub run {


sub load_envfile { sub load_envfile {
my ($self, $file) = @_; my ($self, $file) = @_;
$self->usage unless -f $file;
open my $fh, '<', $file or die "$file: $!\n"; open my $fh, '<', $file or die "$file: $!\n";
while (defined (my $line = readline $fh)) { while (defined (my $line = readline $fh)) {
chomp $line; chomp $line;
Expand Down
7 changes: 6 additions & 1 deletion t/02_load_envfile.t
Expand Up @@ -91,8 +91,13 @@ FOO = bar
ENV ENV


subtest 'file not found' => sub { subtest 'file not found' => sub {
no warnings 'redefine';
*App::envfile::usage = sub {
ok "call this method", "call usage";
die "oops";
};
eval { App::envfile->new->load_envfile('foo.bar') }; eval { App::envfile->new->load_envfile('foo.bar') };
like $@, qr/^foo.bar: No such file or directory/; like $@, qr/oops/;
}; };


done_testing; done_testing;

0 comments on commit 86777e3

Please sign in to comment.