1 Introduction
The Subplot library files
provides scenario steps and their
implementations for managing files on the file system during tests.
The library consists of a bindings file lib/files.yaml
and
implementations in Python in lib/files.py
or in Rust within the
subplotlib
crate.
This document explains the acceptance criteria for the library and how
they're verified. It uses the steps and functions from the files
library.
2 Create on-disk files from embedded files
Subplot allows the source document to embed test files, and the
files
library provides steps to create real, on-disk files from
the embedded files.
1 given file hello.txt
2 then file hello.txt exists
3 then file hello.txt contains "hello, world"
4 then file other.txt does not exist
5 given file other.txt from hello.txt
6 then file other.txt exists
7 then files hello.txt and other.txt match
8 then only files hello.txt, other.txt exist
hello, world
These steps create files and manage their metadata.
1 given file hello.txt
2 when I remember metadata for file hello.txt
3 then file hello.txt has same metadata as before
4 when I write "yo" to file hello.txt
5 then file hello.txt has different metadata from before
4 File modification time
These steps manipulate and test file modification times.
1 given file foo.dat has modification time 1970-01-02 03:04:05
2 then file foo.dat has a very old modification time
3 when I touch file foo.dat
4 then file foo.dat has a very recent modification time
5 File contents
These steps verify contents of files.
1 given file hello.txt
2 then file hello.txt contains "hello, world"
3 then file hello.txt doesn't contain "hello, sailor"
4 then file hello.txt matches regex "hello, .*"
5 then file hello.txt matches regex /hello, .*/
6 File equality
These steps verify contents of files.
1 given file hello.txt
2 given file hi.txt from hello.txt
3 then files hello.txt and hi.txt on disk are identical
4 given file other.txt
5 then files hello.txt and other.txt on disk are different
6 then file hi.txt on disk and embedded file hello.txt are identical
7 then file other.txt on disk and embedded file hello.txt are different
Go away, please.
7 Directories
There are also a large number of directory based steps and some directory
based behaviour available in creating files which are available in the files
library.
1 given a directory first
2 then directory first exists
3 then directory first is empty
4 then directory second does not exist
5 when I remove directory first
6 then directory first does not exist
7 when I create directory second
8 then directory second exists
9 then directory second is empty
10 given file second/third/hello.txt from hello.txt
11 then directory second is not empty
12 then directory second/third exists
13 then directory second/third is not empty
14 when I remove directory second
15 then directory second does not exist
8 File and directory removal
1 given file hello.txt
2 then file hello.txt exists
3 when I remove file hello.txt
4 then file hello.txt does not exist
5 given a directory foo
6 when I remove empty directory foo
7 then directory foo does not exist