Skip to content

Commit d7a1cd0

Browse files
committed
Finished half-finished tests
1 parent f94b33a commit d7a1cd0

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

spec/moq_spec.lua

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

4-
local function shoulFail(test)
4+
local function shouldFail(test)
55
if pcall(test) then
66
error('expected failure did not occur')
77
end
@@ -15,11 +15,12 @@ describe('The mock library', function()
1515
end)
1616

1717
it('should alert you when a function is not called', function()
18-
-- local m = moq.createMockFunction()
18+
shouldFail(function()
19+
local m = moq.createMockFunction()
1920

20-
-- moq.mock(m):shouldBeCalled():
21-
-- when(function() m() end)
22-
error('todo')
21+
moq.mock(m):shouldBeCalled():
22+
when(function() end)
23+
end)
2324
end)
2425

2526
it('should allow you to verify that a function has been called with the correct arguments', function()
@@ -30,11 +31,12 @@ describe('The mock library', function()
3031
end)
3132

3233
it('should alert you when a function has been called with incorrect arguments', function()
33-
-- local m = moq.createMockFunction()
34+
shouldFail(function()
35+
local m = moq.createMockFunction()
3436

35-
-- moq.mock(m):shouldBeCalledWith(1, '2'):
36-
-- when(function() m(1, '2') end)
37-
error('todo')
37+
moq.mock(m):shouldBeCalledWith(1, '2'):
38+
when(function() m(1, '3') end)
39+
end)
3840
end)
3941

4042
it('should allow you to specify the return value of a mocked function', function()
@@ -164,17 +166,18 @@ describe('The mock library', function()
164166
end)
165167

166168
it('should fail when a method is incorrectly used as a function', function()
167-
-- local someObject = {}
169+
shouldFail(function()
170+
local someObject = {}
168171

169-
-- function someObject:foo() end
172+
function someObject:foo() end
170173

171-
-- mockedObject = moq.createMockObject(someObject)
174+
mockedObject = moq.createMockObject(someObject)
172175

173-
-- moq.mock(mockedObject.foo):shouldBeCalledWith(1):andWillReturn(2):
174-
-- when(function()
175-
-- mockedObject.foo(1)
176-
-- end)
177-
error('todo')
176+
moq.mock(mockedObject.foo):shouldBeCalledWith(1):andWillReturn(2):
177+
when(function()
178+
mockedObject.foo(1)
179+
end)
180+
end)
178181
end)
179182

180183
-- ordering

0 commit comments

Comments
 (0)