better test names

This commit is contained in:
kikito 2014-08-16 16:50:29 +02:00
parent e74c899b7d
commit 5ecaca9205

View File

@ -182,39 +182,39 @@ describe( 'inspect', function()
describe('the process option', function()
it('can be used to remove a particular element easily', function()
it('removes one element', function()
local names = {'Andrew', 'Peter', 'Ann' }
local removeAnn = function(item) if item ~= 'Ann' then return item end end
assert.equals(inspect(names, {process = removeAnn}), '{ "Andrew", "Peter" }')
end)
it('can use the path', function()
it('uses the path', function()
local names = {'Andrew', 'Peter', 'Ann' }
local removeThird = function(item, path) if path[1] ~= 3 then return item end end
assert.equals(inspect(names, {process = removeThird}), '{ "Andrew", "Peter" }')
end)
it('can replace values', function()
it('replaces items', function()
local names = {'Andrew', 'Peter', 'Ann' }
local filterAnn = function(item) return item == 'Ann' and '<filtered>' or item end
assert.equals(inspect(names, {process = filterAnn}), '{ "Andrew", "Peter", "<filtered>" }')
end)
it('can nullify metatables', function()
it('nullifies metatables', function()
local mt = {'world'}
local t = setmetatable({'hello'}, mt)
local removeMt = function(item) if item ~= mt then return item end end
assert.equals(inspect(t, {process = removeMt}), '{ "hello" }')
end)
it('can nullify metatables via their paths', function()
it('nullifies metatables using their paths', function()
local mt = {'world'}
local t = setmetatable({'hello'}, mt)
local removeMt = function(item, path) if path[#path] ~= '<metatable>' then return item end end
assert.equals(inspect(t, {process = removeMt}), '{ "hello" }')
end)
it('can nullify the root object', function()
it('nullifies the root object', function()
local names = {'Andrew', 'Peter', 'Ann' }
local removeNames = function(item) if item ~= names then return item end end
assert.equals(inspect(names, {process = removeNames}), 'nil')