File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -643,4 +643,19 @@ describe('The mach library', function()
643
643
end )
644
644
end )
645
645
end )
646
+
647
+ it (' should allow custom matchers to be used' , function ()
648
+ local function always_matches () return true end
649
+ local function never_matches () return false end
650
+
651
+ f :should_be_called_with (mach .match ({ a = 1 , b = 2 }, always_matches )):when (function ()
652
+ f ({ a = 11 , b = 22 })
653
+ end )
654
+
655
+ should_fail (function ()
656
+ f :should_be_called_with (mach .match ({ a = 1 , b = 2 }, never_matches )):when (function ()
657
+ f ({ a = 1 , b = 2 })
658
+ end )
659
+ end )
660
+ end )
646
661
end )
Original file line number Diff line number Diff line change @@ -92,8 +92,8 @@ function mach.mock_object(o, name)
92
92
return mocked
93
93
end
94
94
95
- function mach .match (value )
96
- return setmetatable ({ value = value , matcher = default_matcher }, mach_match )
95
+ function mach .match (value , matcher )
96
+ return setmetatable ({ value = value , matcher = matcher or default_matcher }, mach_match )
97
97
end
98
98
99
99
return setmetatable (mach , { __call = function (_ , ...) return Expectation (... ) end })
You can’t perform that action at this time.
0 commit comments