Skip to content

Commit 2d744ef

Browse files
committed
Test that mocked objects are named (explicitly or implicitly). Closes #2.
1 parent 23037ba commit 2d744ef

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

spec/mach_spec.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,22 @@ describe('The mach library', function()
202202
end)
203203
end)
204204

205+
it('should allow a mocked object to be named', function()
206+
mocked_object = mach.mock_object({ foo = function() end }, 'some_object')
207+
208+
should_fail_with('unexpected function call some_object:foo()', function()
209+
mocked_object.foo()
210+
end)
211+
end)
212+
213+
it('should give mocked objects a default name when none is provided', function()
214+
mocked_object = mach.mock_object({ foo = function() end })
215+
216+
should_fail_with('unexpected function call <anonymous>:foo()', function()
217+
mocked_object.foo()
218+
end)
219+
end)
220+
205221
it('should allow mocking of any callable in an object, not just functions', function()
206222
local some_table = {
207223
foo = {}

0 commit comments

Comments
 (0)