File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ describe('The mach library', function()
146
146
bar = function () end
147
147
}
148
148
149
- mocked_table = mach .mock_table (some_table , ' some_table ' )
149
+ mocked_table = mach .mock_table (some_table )
150
150
151
151
mocked_table .foo :should_be_called_with (1 ):and_will_return (2 ):
152
152
and_also (mocked_table .bar :should_be_called ()):
@@ -156,14 +156,30 @@ describe('The mach library', function()
156
156
end )
157
157
end )
158
158
159
+ it (' should allow a mocked table to be named' , function ()
160
+ mocked_table = mach .mock_table ({ foo = function () end }, ' some_table' )
161
+
162
+ should_fail_with (' unexpected function call some_table.foo()' , function ()
163
+ mocked_table .foo ()
164
+ end )
165
+ end )
166
+
167
+ it (' should give mocked tables a default name when none is provided' , function ()
168
+ mocked_table = mach .mock_table ({ foo = function () end })
169
+
170
+ should_fail_with (' unexpected function call <anonymous>.foo()' , function ()
171
+ mocked_table .foo ()
172
+ end )
173
+ end )
174
+
159
175
it (' should fail when a function is incorrectly used as a method' , function ()
160
- should_fail (function ()
161
- local some_table = {
162
- foo = function () end
163
- }
176
+ local some_table = {
177
+ foo = function () end
178
+ }
164
179
165
- mocked_table = mach .mock_table (some_table )
180
+ mocked_table = mach .mock_table (some_table )
166
181
182
+ should_fail (function ()
167
183
mocked_table .foo :should_be_called_with (1 ):and_will_return (2 ):when (function ()
168
184
mocked_table :foo (1 )
169
185
end )
You can’t perform that action at this time.
0 commit comments