2024-05-28 15:30:41 +12:00
|
|
|
defmodule IgniterTest do
|
|
|
|
use ExUnit.Case
|
|
|
|
doctest Igniter
|
2024-08-21 06:32:02 +12:00
|
|
|
|
2024-09-16 09:19:54 +12:00
|
|
|
import Igniter.Test
|
|
|
|
|
2024-08-21 06:32:02 +12:00
|
|
|
describe "Igniter.copy_template/4" do
|
|
|
|
test "it evaluates and writes the template" do
|
2024-09-16 09:19:54 +12:00
|
|
|
test_project()
|
|
|
|
|> Igniter.copy_template("test/templates/template.css.eex", "lib/foobar.css",
|
|
|
|
class: "hello"
|
|
|
|
)
|
|
|
|
|> assert_creates("lib/foobar.css", """
|
|
|
|
.hello {
|
|
|
|
background: black
|
|
|
|
}
|
|
|
|
""")
|
|
|
|
end
|
2024-08-21 06:32:02 +12:00
|
|
|
|
2024-09-16 09:19:54 +12:00
|
|
|
test "it overwrites an existing file" do
|
|
|
|
test_project()
|
|
|
|
|> Igniter.copy_template("test/templates/template.css.eex", "lib/foobar.css",
|
|
|
|
class: "hello"
|
|
|
|
)
|
|
|
|
|> apply_igniter!()
|
|
|
|
|> Igniter.copy_template(
|
|
|
|
"test/templates/template.css.eex",
|
|
|
|
"lib/foobar.css",
|
|
|
|
[class: "goodbye"],
|
|
|
|
on_exists: :overwrite
|
|
|
|
)
|
|
|
|
|> assert_has_patch("lib/foobar.css", """
|
|
|
|
1 - |.hello {
|
|
|
|
1 + |.goodbye {
|
|
|
|
""")
|
2024-08-21 06:32:02 +12:00
|
|
|
end
|
|
|
|
end
|
2024-05-28 15:30:41 +12:00
|
|
|
end
|