Skip to content

Commit

Permalink
Merge pull request #1049 from kiwiroy/more-file-tests
Browse files Browse the repository at this point in the history
add doc on passing arguments and tests to check pass though to File::…
  • Loading branch information
kraih committed Feb 3, 2017
2 parents 515f363 + 2839f17 commit f48e67a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Mojo/File.pm
Expand Up @@ -281,8 +281,10 @@ Include hidden files and directories.
=head2 make_path
$path = $path->make_path;
$path = $path->make_path({mode => 0711});
Create the directories if they don't already exist with L<File::Path>.
Create the directories if they don't already exist with L<File::Path>. Any
additional arguments are passed through unmodified to L<File::Path::make_path>.
=head2 move_to
Expand All @@ -306,9 +308,11 @@ directory.
=head2 remove_tree
$path = $path->remove_tree;
$path = $path->remove_tree({keep_root => 1});
Delete this directory and any files and subdirectories it may contain with
L<File::Path>.
L<File::Path>. Any additional arguments are passed through unmodified to
L<File::Path::remove_tree>.
=head2 slurp
Expand Down
7 changes: 7 additions & 0 deletions t/mojo/file.t
Expand Up @@ -70,11 +70,18 @@ my $subdir = $dir->child('foo', 'bar');
ok !-d $subdir, 'directory does not exist anymore';
$subdir->make_path;
ok -d $subdir, 'directory exists';
my $nextdir = $dir->child('foo', 'foobar')->make_path({error => \my $error});
ok -d $nextdir, 'directory exists';
isa_ok $error, 'ARRAY', 'make_path modified variable';

# Remove tree
$dir = tempdir;
$dir->child('foo', 'bar')->make_path->child('test.txt')->spurt('test!');
is $dir->child('foo', 'bar', 'test.txt')->slurp, 'test!', 'right content';
$subdir = $dir->child('foo', 'foobar')->make_path;
ok -e $subdir->child('bar')->make_path->child('a.out')->spurt('ELF'), 'created';
ok -d $subdir->remove_tree({keep_root => 1}), 'arg passed through and dir kept';
ok !-e $subdir->child('bar'), 'sub tree has been removed';
ok !-e $dir->child('foo')->remove_tree->to_string, 'tree has been removed';

# Move to
Expand Down

0 comments on commit f48e67a

Please sign in to comment.