1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# Bind steps to functions that implement them. Each step is
# represented as a dict in a list with specific keys in the dict.
#
# given/when/then: specifies the keyword and a regexp that matches the
# step text, and captures parts of the step, using special syntax to
# name each match
#
# args: specifies type of each named match (argument), with type names
# being str (any text), int, pathname, ...
#
# function: name of function to be called, which will get the named
# arguments as parameters, in the order given in the regexp; function
# should return a value that indicates success or failure, and can
# contain values with more detail. Might be Rust enums or Python
# dict objects.
#
# capture_result: if set to true, a successful result is stored for
# inspection by a later step. It's a parse-time error is the step is
# not inspected by a later step in the scenario. Failure result still
# fails the step.
#
# use_captured_result: if set to true, the captured result is given to
# the function in a specific way, which depends on the language used
# to implement the function (e.g., keyword arg in Python).
#
# set_it: a specific argument captured from the step is remembered as
# "it".
#
# it: expects a value for "it" to have been rememered by a previous
# step, and the value must be of the specified type. If it isn't,
# that's a parsing-time error.
- given: an empty journal repository
function: create_empty_git_repository
- then: there is only (filename:\S+) in the journal repository
args:
filename: pathname
function: only_filename
- when: I run (cmd:jt .+)
args:
cmd: {type: str, style: literal}
capture_result: true
function: run_jt
- then: (filename:\S+) exists
args:
filename: pathname
set_it: filename
function: exists
- then: it contains "(text:.+)"
args:
text: str
it: pathname
function: file_contains
- then: it fails
use_captured_result: true
function: shell_command_failed
- then: it fails with (error:.+)
args:
error: str
use_captured_result: true
function: stderr_contains
- given: the date is (date:\d+-\d+-\d+)
args:
date: str
function: set_date
|