Skip to content

Commit 5a4b143

Browse files
committed
Iterate over code examples in tests
1 parent c9c42d2 commit 5a4b143

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

_data/code.yml

+9
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,12 @@
3232
</div>
3333
</body>
3434
</html>
35+
36+
37+
- title: Nope
38+
text: >
39+
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
40+
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
41+
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
42+
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
43+
amet.

_test/reference_test.exs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
defmodule ReferenceTest do
2+
use ExUnit.Case
3+
4+
paths = "_data/*.yml" |> Path.wildcard
5+
6+
{:ok, counter} = Agent.start_link fn-> 0 end
7+
8+
9+
for path <- paths,
10+
document = YAML.read(path),
11+
section <- document,
12+
section["slime"],
13+
section["output"]
14+
do
15+
n = Agent.get counter, fn x -> x end
16+
Agent.update counter, fn x -> x + 1 end
17+
18+
test "code example #{n} (in #{path})" do
19+
20+
end
21+
end
22+
end

0 commit comments

Comments
 (0)