Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions spec/example_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,48 @@ describe("Busted unit testing framework", function()
it("should provide some shortcuts to common functions", function()
assert.are.unique({{ thing = 1 }, { thing = 2 }, { thing = 3 }})
end)

it("should present failed assertions with FAILED", function()
assert.falsy(0)
end)

it("should present failed assertions with custom message", function()
assert.are.same(13, 42, "Incorrect answer for input n=10")
end)

describe("should present errors in IT with LOG", function()
it("IT with an error", function()
local nilobj = nil
nilobj.test()
assert.falsy(0)
end)
end)

describe("should present errors in describe with ERROR", function()

local nilobj = nil
nilobj.test()

it("dummy IT", function()
assert.falsy(0)
end)
end)

describe("should present errors in IT titles with ERROR", function()
local nilobj = nil
it("it block with ERROR" .. nilobj.test(), function()
assert.falsy(0)
end)
end)
end)

describe("Should support newlines\nin group titles", function()
it("Should support newlines\nin test titles", function()
assert.truthy(0, "Should support newlines\nin assertion messages")
end)
it("Should support newlines\nin errors", function()
error("Error message with...\n a newline")
assert.truthy(0)
end)
end)
end)
11 changes: 5 additions & 6 deletions src/busted/outputHandlers/codewars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ return function(options)
end

local function onDescribeStart(element, parent)
print('\n<DESCRIBE::>' .. element.name)
print('\n<DESCRIBE::>' .. escape(element.name))
return nil, true
end
local function onDescribeEnd(element, parent)
Expand All @@ -16,7 +16,7 @@ return function(options)
end

local function onTestStart(element, parent)
print('\n<IT::>' .. element.name)
print('\n<IT::>' .. escape(element.name))
return nil, true
end
local function onTestEnd(element, parent, status, trace)
Expand All @@ -29,9 +29,9 @@ return function(options)
end

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

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

local function onError(element, parent, message, debug)
if element.descriptor ~= 'it' then
print('\n<ERROR::>Error')
print('\n<LOG:ESC:>' .. escape(message))
print('\n<ERROR::>Error<:LF:>' .. escape(message))
end
return nil, true
end
Expand Down