-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add tests for
Vox.partial/2
(#44)
Adds tests for `Vox.partial/2`. I anticipate very quickly refactoring this so that the ultimate call isn't made to `Vox.Builder.FileCompiler.partial/2`. I'd like to put that somewhere else. But these tests will help me have confidence in that refactoring. Progresses #31
- Loading branch information
Showing
3 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div id="with-assigns"> | ||
This should render an assign: <%= @title %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div id="without-assigns"> | ||
This should render without an assign | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,24 @@ | ||
defmodule VoxTest do | ||
use ExUnit.Case | ||
doctest Vox | ||
|
||
describe "partial/2" do | ||
test "raises without a leading slash for the partial's path" do | ||
assert_raise RuntimeError, fn -> | ||
Vox.partial("improper-path.html.eex") | ||
end | ||
end | ||
|
||
test "renders a file with assigns" do | ||
result = Vox.partial("/partials/with-assigns.html.eex", title: "Hello, Vox!") | ||
assert result =~ "id=\"with-assigns\"" | ||
assert result =~ "Hello, Vox!" | ||
refute result =~ "@title" | ||
end | ||
|
||
test "renders a file without assigns" do | ||
result = Vox.partial("/partials/without-assigns.html.eex") | ||
assert result =~ "id=\"without-assigns\"" | ||
end | ||
end | ||
end |