summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcheck9
-rw-r--r--my-sites.md19
-rw-r--r--my-sites.py11
-rw-r--r--my-sites.yaml5
4 files changed, 44 insertions, 0 deletions
diff --git a/check b/check
new file mode 100755
index 0000000..6fa29e0
--- /dev/null
+++ b/check
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+set -euo pipefail
+
+sp-docgen my-sites.md -o my-sites.html
+sp-docgen my-sites.md -o my-sites.pdf
+sp-codegen my-sites.md -o test.py
+rm -f test.log
+python3 test.py --log test.log "$@"
diff --git a/my-sites.md b/my-sites.md
new file mode 100644
index 0000000..e2b67ab
--- /dev/null
+++ b/my-sites.md
@@ -0,0 +1,19 @@
+# Introduction
+
+This is a simplistic set of acceptance criteria for my various
+websites.
+
+# liw.fi
+
+~~~scenario
+when I fetch https://liw.fi
+then page contains "I am Lars Wirzenius"
+~~~
+
+---
+title: Do my sites work?
+author: Lars Wirzenius
+template: python
+bindings: my-sites.yaml
+functions: my-sites.py
+...
diff --git a/my-sites.py b/my-sites.py
new file mode 100644
index 0000000..f01eea9
--- /dev/null
+++ b/my-sites.py
@@ -0,0 +1,11 @@
+import requests
+
+def fetch(ctx, url=None):
+ r = requests.get(url)
+ assert r.ok
+ ctx["page"] = r.text
+
+def contains(ctx, text=None):
+ if text not in ctx["page"]:
+ print(f"page does not contain {text!r}")
+ assert 0
diff --git a/my-sites.yaml b/my-sites.yaml
new file mode 100644
index 0000000..a1783fa
--- /dev/null
+++ b/my-sites.yaml
@@ -0,0 +1,5 @@
+- when: I fetch {url}
+ function: fetch
+
+- then: page contains "{text:text}"
+ function: contains