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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
---
title: JT acceptance tests v1
author: Lars Wirzenius / The Ick project
...
# Introduction
JT is a command line tool for writing entries in my personal journal.
It works by adding files to the git repository with the journal, for
formatting by the Ikiwiki website compiler. This
document presents its automated acceptance tests, using a (for now
hypothetical) language similar to the Gherkin langauge implemented by
Cucumber.
All of these scenarios start with an empty directory and with JT
configured to put drafts in the `drafts` directory, topics in
`topics`, and finished journal entries in `notes`.
# Happy path scenarios
## Add a journal entry
We start off with an empty journal repository. We only test that it's
empty here; all other scenarios assume this works.
> *given* an empty journal repository
> *then* there is only **_.git_** in the journal repository
We create a draft journal entry.
> *when* I run `jt new "my title"`
> *then* **_drafts/0.mdwn_** exists
> *and* it contains **_"my title"_**
When we finish the entry, the draft is moved to the notes directory.
> *given* the date is **_2019-09-01_**
> *when* I run `jt finish`
> *then* **_notes/2019/09/01/my_title.mdwn_** exists
> *and* it contains **_"my title"_**
## Add a journal entry with an attachment
This is similar to adding a journal entry, except it adds an
attachment to the new entry. The attachment could be anything, such as
a photo.
> *given* an empty journal repository
> *when* I run `jt new "my title"`
> *then* **_drafts/0.mdwn_** exists
> *and* it contains **_"my title"_**
The attachment file needs to exist. It gets copied to the drafts
directory.
> *given* the file `photo.jpg` exists
> *when* I run `jt attach 0 photo.jpg`
> *then* **_drafts/0/photo.jpg_** exists
When we finish the entry, the draft is moved to the notes directory,
with the attachment.
> *given* the date is **_2019-09-01_**
> *when* I run `jt finish`
> *then* **_notes/2019/09/01/my_title.mdwn_** exists
> *and* it contains **_"my title"_**
> *and* **_notes/2019/09/01/my_title/photo.jpg_** exists
## Add a topic
JT allows "topic", which are meant to be pages that collect entries of
specific topics. The formatted journal will have a page for each topic
shows all entries that reference that topic. Similar to tags, but
another dimension of metadata. It's up to the user to use tags or
topics as they wish.
> *given* an empty journal repository
> *when* I run `jt new-topic 2019/my-project`
> *then* **_topics/2019/my-project.mdwn_** exists
One can add an entry for a topic, but it must exist.
> *when* I run `jt new --topic nonexistent "my title"`
> *then* it fails
> *when* I run `jt new --topic 2019/my-project "my title"`
> *then* **drafts/0.mdwn_** exists
> *and* it contains **_"2019/my-project"_**
# Unhappy path scenarios
## Finishing when there's more than one draft
JT will pick the draft to act on if there's only one current draft. If
there's more, it will fail with an error message saying "too many
drafts".
> *given* an empty journal repository
> *when* I run `jt new "first"`
> *then* **drafts/0.mdwn_** exists
> *when* I run `jt new "second"`
> *then* **drafts/1.mdwn_** exists
> *when* I run `jt finish`
> *then* it fails with `"too many drafts"`
## Attaching when there's no such draft
Attaching to a draft that doesn't exist doesn't work.
> *given* an empty journal repository
> *and* the file `photo.jpg` exists
> *when* I run `jt attach 0 photo.jpg`
> *then* it fails with `"no such draft"`
## Attaching when there's no such file
Attaching a file that doesn't exist doesn't work.
> *given* an empty journal repository
> *when* I run `jt new "first"`
> *and* I run `jt attach 0 photo.jpg`
> *then* it fails with `"no such file"`
|