Skip to content

Commit f94b33a

Browse files
committed
Added more and better tests
1 parent 02cf149 commit f94b33a

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

spec/moq_spec.lua

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
describe('The mock library', function()
22
moq = require 'moq'
33

4+
local function shoulFail(test)
5+
if pcall(test) then
6+
error('expected failure did not occur')
7+
end
8+
end
9+
410
it('should allow you to verify that a function is called', function()
511
local m = moq.createMockFunction()
612

@@ -127,17 +133,18 @@ describe('The mock library', function()
127133
end)
128134

129135
it('should fail when a function is incorrectly used as a method', function()
130-
-- local someTable = {
131-
-- foo = function() end
132-
-- }
136+
shouldFail(function()
137+
local someTable = {
138+
foo = function() end
139+
}
133140

134-
-- mockedTable = moq.createMockTable(someTable)
141+
mockedTable = moq.createMockTable(someTable)
135142

136-
-- moq.mock(mockedTable.foo):shouldBeCalledWith(1):andWillReturn(2):
137-
-- when(function()
138-
-- mockedTable:foo(1)
139-
-- end
140-
error('todo')
143+
moq.mock(mockedTable.foo):shouldBeCalledWith(1):andWillReturn(2):
144+
when(function()
145+
mockedTable:foo(1)
146+
end)
147+
end)
141148
end)
142149

143150
it('should allow an object with methods to be mocked', function()

0 commit comments

Comments
 (0)