Skip to content

Commit 1a2f5a0

Browse files
committed
Slight improvement to failure message for unexpected calls
1 parent ea61543 commit 1a2f5a0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

mock.lua

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ local Mock = {}
22

33

44

5-
local subscriber
5+
local callbacks
66

7-
local function mockHandle(callback, thunk)
8-
subscriber = callback
7+
function mockHandle(callback, thunk)
8+
callbacks[callback] = true
99
thunk()
10-
subscriber = nil
10+
callbacks[callback] = nil
1111
end
1212

13-
local function mockCalled(m, name, args)
14-
return subscriber(m, name, args)
13+
function mockCalled(m, name, args)
14+
for callback in callbacks do
15+
callback(m, name, args)
16+
end
1517
end
1618

1719

0 commit comments

Comments
 (0)