forked from haml/haml-spec
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlua_haml_spec.lua
30 lines (26 loc) · 880 Bytes
/
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
require 'luarocks.require'
require 'json'
require 'telescope'
require 'haml'
local function get_tests(filename)
local self = debug.getinfo(1).short_src
if self:match("/") then return "./" .. self:gsub("[^/]*%.lua$", "/" .. filename)
elseif self:match("\\") then return self:gsub("[^\\]*%.lua$", "\\" .. filename)
else return filename
end
end
local fh = assert(io.open(get_tests("tests-new.json")))
local input = fh:read '*a'
fh: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(string.format("should correctly render %s", name), function()
assert_equal(haml.render(exp.haml, exp.config or {}, exp.locals or {}), exp.html)
end)
end
end)
end
end)