Skip to content

Commit c37dfb1

Browse files
committed
Test code examples
1 parent 5a4b143 commit c37dfb1

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

_data/code.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
html
1111
head
1212
meta name="keywords" description="Slime"
13-
title= site_title
13+
title= String.capitalize "slime"
1414
body
1515
#id.class
1616
ul
@@ -21,7 +21,7 @@
2121
<html>
2222
<head>
2323
<meta name="keywords" description="Slime">
24-
<title>Website Title</title>
24+
<title>Slime</title>
2525
</head>
2626
<body>
2727
<div class="class" id="id">

_test/reference_test.exs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
defmodule ReferenceTest do
22
use ExUnit.Case
3+
require Slime
34

45
paths = "_data/*.yml" |> Path.wildcard
56

@@ -16,7 +17,10 @@ defmodule ReferenceTest do
1617
Agent.update counter, fn x -> x + 1 end
1718

1819
test "code example #{n} (in #{path})" do
19-
20+
slime = unquote(section["slime"])
21+
expected = unquote(section["output"])
22+
output = slime |> Slime.render
23+
assert HTML.minify(expected) == output
2024
end
2125
end
2226
end

mix.exs

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ defmodule SlimeReference.Mixfile do
2323

2424
defp deps do
2525
[
26+
# Slime!
27+
{:slime, "~> 0.0"},
2628
# Automatic test runner
2729
{:mix_test_watch, only: :dev},
2830
# Style linter

mix.lock

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
"fs": {:hex, :fs, "0.9.2"},
33
"mix_test_watch": {:hex, :mix_test_watch, "0.2.4"},
44
"poison": {:hex, :poison, "1.5.0"},
5+
"slime": {:hex, :slime, "0.11.0"},
56
"yamerl": {:git, "https://github.com/yakaz/yamerl.git", "ae810a808817d9482b4628ae3e20d746e3729fe0", []}}

0 commit comments

Comments
 (0)