Skip to content

Commit aeba3c5

Browse files
committed
Added ignore_mocked_calls_when
1 parent 7325769 commit aeba3c5

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

publish-to-lit.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local f = io.open('build/mach.lua', 'w')
55
f:write([==[
66
--[[lit-meta
77
name = 'ryanplusplus/mach'
8-
version = '1.0.8'
8+
version = '1.0.11'
99
description = 'Simple mocking framework for Lua inspired by CppUMock and designed for readability.'
1010
tags = { 'testing' }
1111
license = 'MIT'

spec/mach_spec.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,4 +727,10 @@ describe('The mach library', function()
727727
end)
728728
end)
729729
end)
730+
731+
it('should allow mocked calls to be ignored', function()
732+
mach.ignore_mocked_calls_when(function()
733+
f()
734+
end)
735+
end)
730736
end)

src/mach.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,10 @@ function mach.match(value, matcher)
104104
return setmetatable({ value = value, matcher = matcher or default_matcher }, mach_match)
105105
end
106106

107+
function mach.ignore_mocked_calls_when(thunk)
108+
subscriber = load''
109+
thunk()
110+
subscriber = unexpected_call
111+
end
112+
107113
return mach

0 commit comments

Comments
 (0)