File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change 1
1
describe (' The mock library' , function ()
2
2
moq = require ' moq'
3
3
4
+ local function shoulFail (test )
5
+ if pcall (test ) then
6
+ error (' expected failure did not occur' )
7
+ end
8
+ end
9
+
4
10
it (' should allow you to verify that a function is called' , function ()
5
11
local m = moq .createMockFunction ()
6
12
@@ -127,17 +133,18 @@ describe('The mock library', function()
127
133
end )
128
134
129
135
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
+ }
133
140
134
- -- mockedTable = moq.createMockTable(someTable)
141
+ mockedTable = moq .createMockTable (someTable )
135
142
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 )
141
148
end )
142
149
143
150
it (' should allow an object with methods to be mocked' , function ()
You can’t perform that action at this time.
0 commit comments