summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-11-22 17:48:38 +0200
committerLars Wirzenius <liw@liw.fi>2014-11-22 17:48:38 +0200
commitbd7f026a8141ab44f8f8d5e2f2a6bfcad8c73d4a (patch)
tree460595ef07fee591fd7acbbbbd3f6cf693cc7454
parent72273168fa4b23077fdfe39556d043c1295fb246 (diff)
downloadjt-bd7f026a8141ab44f8f8d5e2f2a6bfcad8c73d4a.tar.gz
Add a basic note creation scenario
-rw-r--r--yarns/020-basic-workflow.yarn26
-rw-r--r--yarns/900-implementations.yarn90
2 files changed, 116 insertions, 0 deletions
diff --git a/yarns/020-basic-workflow.yarn b/yarns/020-basic-workflow.yarn
new file mode 100644
index 0000000..2572076
--- /dev/null
+++ b/yarns/020-basic-workflow.yarn
@@ -0,0 +1,26 @@
+Basic Workflow
+==============
+
+This chapter explains the basic workflow for adding notes.
+
+Notes are first created as drafts. Normally, when a draft is created,
+`jt` invokes the user's preferred editor (`$VISUAL` or `$EDITOR`) on
+the draft file. When the user is finished, they exit their editor and
+run `jt finish`. The test suite is rigged so that the editor isn't
+invoked, because it'd be difficult to control the editor.
+
+ SCENARIO add a simple note
+ GIVEN an empty journal in SRC
+ AND the time is 2014-11-22 17:30:45
+ WHEN I run jt new TITLE
+ THEN file SRC/drafts/0.mdwn exists
+ AND file SRC/drafts/0.mdwn matches title="TITLE"
+
+This is where the user would normally use their editor to edit the
+draft, and exit the editor when done.
+
+ WHEN I run jt finish
+ THEN file SRC/drafts/0.mdwn doesn't exist
+ AND file SRC/notes/2014/11/22/title.mdwn exists
+
+This is how you create a note, in the simplest case.
diff --git a/yarns/900-implementations.yarn b/yarns/900-implementations.yarn
new file mode 100644
index 0000000..35398a6
--- /dev/null
+++ b/yarns/900-implementations.yarn
@@ -0,0 +1,90 @@
+Implementatios of scenario steps
+================================
+
+This chapter contains implementations for the various steps used in
+the scenarios above.
+
+
+No use of git
+-------------
+
+The test suite won't be using git. Normally `jt` would add new notes
+to git, and commit them, but there's no need for that during the test
+suite. That part either works or it doesn't, and it's simple enough
+that it almost certainly will work. (Go on, make me eat my words.)
+However, running git adds more complexity to the test suite, such as
+dealing with the git configuration, or lack thereof, of the user
+running the test suite.
+
+
+Set up an empty journal
+-----------------------
+
+For tests, we need an empty journal.
+
+ IMPLEMENTS GIVEN an empty journal in (\S+)
+ mkdir "$DATADIR/$MATCH_1"
+ cat <<EOF > "$DATADIR/source.conf"
+ [config]
+ source = $DATADIR/$MATCH_1
+ EOF
+
+
+Keeping time
+------------
+
+For various things we need to pretend we know what the time is. For
+example, we may need to test that a filename is generated correctly
+from the current timestamp. Because of this, `jt` has a
+`--pretend-time` setting, which we will use extensively in the test
+suite.
+
+Within the test suite we implement this by having a `time.conf`
+configuration file, created by a "GIVEN the time is ..." step, and
+making sure we give that configuration file to `jt` when it's run by
+the test suite.
+
+ IMPLEMENTS GIVEN the time is (\d{4}-\d\d-\d\d \d\d:\d\d:\d\d)
+ cat <<EOF > "$DATADIR/time.conf"
+ [config]
+ pretend-time = $MATCH_1
+ EOF
+
+
+Running jt commands
+-------------------
+
+We run `jt` from the source tree, without any configurations from the
+user, and with specific settings to make the test suite run smoother.
+
+ IMPLEMENTS WHEN I run jt (.*)
+ EDITOR=true \
+ "$SRCDIR/jt" --no-default-config \
+ --config "$DATADIR/source.conf" \
+ --config "$DATADIR/time.conf" \
+ --layout=pkb \
+ --no-git \
+ $MATCH_1
+
+
+Checking file existence
+-----------------------
+
+Does a file exist?
+
+ IMPLEMENTS THEN file (\S+) exists
+ test -e "$DATADIR/$MATCH_1"
+
+Does a file _not_ exist?
+
+ IMPLEMENTS THEN file (\S+) doesn't exist
+ ! test -e "$DATADIR/$MATCH_1"
+
+
+Checking file contents
+----------------------
+
+Does a file match a regular expression?
+
+ IMPLEMENTS THEN file (\S+) matches (\S+)
+ grep -e "$MATCH_2" "$DATADIR/$MATCH_1"