summaryrefslogtreecommitdiff
path: root/t/spin/file.t
diff options
context:
space:
mode:
Diffstat (limited to 't/spin/file.t')
-rwxr-xr-xt/spin/file.t26
1 files changed, 10 insertions, 16 deletions
diff --git a/t/spin/file.t b/t/spin/file.t
index 2f645e5..260b03e 100755
--- a/t/spin/file.t
+++ b/t/spin/file.t
@@ -2,7 +2,7 @@
#
# Test running spin on a single file.
#
-# Copyright 2021 Russ Allbery <rra@cpan.org>
+# Copyright 2021-2022 Russ Allbery <rra@cpan.org>
#
# SPDX-License-Identifier: MIT
@@ -13,11 +13,8 @@ use warnings;
use lib 't/lib';
use Capture::Tiny qw(capture_stdout);
-use Cwd qw(getcwd);
use Fcntl qw(SEEK_SET);
-use File::Spec;
-use File::Temp;
-use Perl6::Slurp qw(slurp);
+use Path::Tiny qw(path);
use Test::DocKnot::Spin qw(is_spin_output);
use Test::More tests => 3;
@@ -25,22 +22,19 @@ use Test::More tests => 3;
require_ok('App::DocKnot::Spin::Thread');
# Spin a single file.
-my $tempfile = File::Temp->new();
-my $datadir = File::Spec->catfile('t', 'data', 'spin');
-my $inputdir = File::Spec->catfile($datadir, 'input');
-my $input = File::Spec->catfile($inputdir, 'index.th');
-my $expected = File::Spec->catfile($datadir, 'output', 'index.html');
+my $tempfile = Path::Tiny->tempfile();
+my $datadir = path('t', 'data', 'spin');
+my $inputdir = $datadir->child('input');
+my $input = $inputdir->child('index.th');
+my $expected = $datadir->child('output', 'index.html');
my $spin
= App::DocKnot::Spin::Thread->new({ 'style-url' => '/~eagle/styles/' });
-$spin->spin_thread_file($input, $tempfile->filename);
+$spin->spin_thread_file($input, $tempfile);
is_spin_output($tempfile, $expected, 'spin_thread_file with output path');
# The same but spin to standard output.
my $html = capture_stdout {
$spin->spin_thread_file($input);
};
-$tempfile->seek(0, SEEK_SET);
-$tempfile->truncate(0);
-print {$tempfile} $html or die "Cannot write to $tempfile: $!\n";
-$tempfile->flush();
-is_spin_output($tempfile->filename, $expected, 'spin_thread_file to stdout');
+$tempfile->spew($html);
+is_spin_output($tempfile, $expected, 'spin_thread_file to stdout');