Skip to content

Commit e2016f6

Browse files
authored
Merge pull request #1 from hobovsky/main
2 parents 77b9821 + a5e1be5 commit e2016f6

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

spec/example_spec.lua

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,48 @@ describe("Busted unit testing framework", function()
2424
it("should provide some shortcuts to common functions", function()
2525
assert.are.unique({{ thing = 1 }, { thing = 2 }, { thing = 3 }})
2626
end)
27+
28+
it("should present failed assertions with FAILED", function()
29+
assert.falsy(0)
30+
end)
31+
32+
it("should present failed assertions with custom message", function()
33+
assert.are.same(13, 42, "Incorrect answer for input n=10")
34+
end)
35+
36+
describe("should present errors in IT with LOG", function()
37+
it("IT with an error", function()
38+
local nilobj = nil
39+
nilobj.test()
40+
assert.falsy(0)
41+
end)
42+
end)
43+
44+
describe("should present errors in describe with ERROR", function()
45+
46+
local nilobj = nil
47+
nilobj.test()
48+
49+
it("dummy IT", function()
50+
assert.falsy(0)
51+
end)
52+
end)
53+
54+
describe("should present errors in IT titles with ERROR", function()
55+
local nilobj = nil
56+
it("it block with ERROR" .. nilobj.test(), function()
57+
assert.falsy(0)
58+
end)
59+
end)
60+
end)
61+
62+
describe("Should support newlines\nin group titles", function()
63+
it("Should support newlines\nin test titles", function()
64+
assert.truthy(0, "Should support newlines\nin assertion messages")
65+
end)
66+
it("Should support newlines\nin errors", function()
67+
error("Error message with...\n a newline")
68+
assert.truthy(0)
69+
end)
2770
end)
2871
end)

src/busted/outputHandlers/codewars.lua

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ return function(options)
66
end
77

88
local function onDescribeStart(element, parent)
9-
print('\n<DESCRIBE::>' .. element.name)
9+
print('\n<DESCRIBE::>' .. escape(element.name))
1010
return nil, true
1111
end
1212
local function onDescribeEnd(element, parent)
@@ -16,7 +16,7 @@ return function(options)
1616
end
1717

1818
local function onTestStart(element, parent)
19-
print('\n<IT::>' .. element.name)
19+
print('\n<IT::>' .. escape(element.name))
2020
return nil, true
2121
end
2222
local function onTestEnd(element, parent, status, trace)
@@ -29,9 +29,9 @@ return function(options)
2929
end
3030

3131
local function onTestFailure(element, parent, message, debug)
32-
print('\n<FAILED::>Test Failed')
3332
-- remove '/home/codewarrior/lua/fixture.lua:\d+: ' from message
34-
print('\n<LOG:ESC:>' .. escape(message:sub(message:find(' ') + 1)))
33+
local msg = escape(message:sub(message:find(' ') + 1))
34+
print('\n<FAILED::>' .. msg)
3535
return nil, true
3636
end
3737

@@ -43,8 +43,7 @@ return function(options)
4343

4444
local function onError(element, parent, message, debug)
4545
if element.descriptor ~= 'it' then
46-
print('\n<ERROR::>Error')
47-
print('\n<LOG:ESC:>' .. escape(message))
46+
print('\n<ERROR::>Error<:LF:>' .. escape(message))
4847
end
4948
return nil, true
5049
end

0 commit comments

Comments
 (0)