Skip to content

Commit

Permalink
Added ignore_mocked_calls_when
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanplusplus committed Mar 24, 2017
1 parent 7325769 commit aeba3c5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion publish-to-lit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local f = io.open('build/mach.lua', 'w')
f:write([==[
--[[lit-meta
name = 'ryanplusplus/mach'
version = '1.0.8'
version = '1.0.11'
description = 'Simple mocking framework for Lua inspired by CppUMock and designed for readability.'
tags = { 'testing' }
license = 'MIT'
Expand Down
6 changes: 6 additions & 0 deletions spec/mach_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -727,4 +727,10 @@ describe('The mach library', function()
end)
end)
end)

it('should allow mocked calls to be ignored', function()
mach.ignore_mocked_calls_when(function()
f()
end)
end)
end)
6 changes: 6 additions & 0 deletions src/mach.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ function mach.match(value, matcher)
return setmetatable({ value = value, matcher = matcher or default_matcher }, mach_match)
end

function mach.ignore_mocked_calls_when(thunk)
subscriber = load''
thunk()
subscriber = unexpected_call
end

return mach

0 comments on commit aeba3c5

Please sign in to comment.