Skip to content

Commit 7865cbf

Browse files
committed
Print <mach.match(tostring(value))> for an argument that uses a matcher. Closes #19.
1 parent a514037 commit 7865cbf

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

spec/mach_spec.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,19 @@ describe('The mach library', function()
657657
end)
658658
end)
659659

660+
it('should print mach.match arguments in a friendly way', function()
661+
local expected_failure =
662+
'Unexpected arguments (4) provided to function f\n' ..
663+
'Incomplete calls:\n' ..
664+
'\tf(<mach.match(3)>)'
665+
666+
should_fail_with_exactly(expected_failure, function()
667+
f:should_be_called_with(mach.match(3)):when(function()
668+
f(4)
669+
end)
670+
end)
671+
end)
672+
660673
it('should allow custom matchers to be used', function()
661674
local function always_matches() return true end
662675
local function never_matches() return false end

src/mach/match.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
return {}
1+
return {
2+
__tostring = function(o)
3+
return '<mach.match(' .. tostring(o.value) .. ')>'
4+
end
5+
}

0 commit comments

Comments
 (0)