1
1
describe (' The mock library' , function ()
2
2
moq = require ' moq'
3
3
4
- local function shoulFail (test )
4
+ local function shouldFail (test )
5
5
if pcall (test ) then
6
6
error (' expected failure did not occur' )
7
7
end
@@ -15,11 +15,12 @@ describe('The mock library', function()
15
15
end )
16
16
17
17
it (' should alert you when a function is not called' , function ()
18
- -- local m = moq.createMockFunction()
18
+ shouldFail (function ()
19
+ local m = moq .createMockFunction ()
19
20
20
- -- moq.mock(m):shouldBeCalled():
21
- -- when(function() m () end)
22
- error ( ' todo ' )
21
+ moq .mock (m ):shouldBeCalled ():
22
+ when (function () end )
23
+ end )
23
24
end )
24
25
25
26
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()
30
31
end )
31
32
32
33
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 ()
34
36
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 )
38
40
end )
39
41
40
42
it (' should allow you to specify the return value of a mocked function' , function ()
@@ -164,17 +166,18 @@ describe('The mock library', function()
164
166
end )
165
167
166
168
it (' should fail when a method is incorrectly used as a function' , function ()
167
- -- local someObject = {}
169
+ shouldFail (function ()
170
+ local someObject = {}
168
171
169
- -- function someObject:foo() end
172
+ function someObject :foo () end
170
173
171
- -- mockedObject = moq.createMockObject(someObject)
174
+ mockedObject = moq .createMockObject (someObject )
172
175
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 )
178
181
end )
179
182
180
183
-- ordering
0 commit comments