-
Notifications
You must be signed in to change notification settings - Fork 18
/
lua_haml_spec.lua
38 lines (33 loc) · 1.07 KB
/
lua_haml_spec.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
local dir = require 'pl.dir'
local haml = require 'haml'
local json = require 'json'
local path = require 'pl.path'
local telescope = require 'telescope'
local assert = assert
local describe = telescope.describe
local getinfo = debug.getinfo
local it = telescope.it
local open = io.open
local pairs = pairs
module('hamlspec')
local function get_tests(filename)
local me = path.abspath(getinfo(1).source:match("@(.*)$"))
return path.join(path.dirname(me), filename)
end
local json_file = get_tests("tests.json")
local file = assert(open(json_file))
local input = file:read '*a'
file:close()
local contexts = json.decode(input)
describe("LuaHaml", function()
for context, expectations in pairs(contexts) do
describe("When handling " .. context, function()
for name, exp in pairs(expectations) do
it(("should correctly render %s"):format(name), function()
local engine = haml.new(exp.config)
assert_equal(engine:render(exp.haml, exp.locals), exp.html)
end)
end
end)
end
end)