Skip to content

Commit 0540203

Browse files
committed
Correctly print out expectations created with should_be_called_with_any_arguments. Closes #22.
1 parent 885b240 commit 0540203

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

spec/mach_spec.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,4 +733,21 @@ describe('The mach library', function()
733733
f()
734734
end)
735735
end)
736+
737+
it('should correctly print arguments for incomplete expectations that accept any arguments', function()
738+
local expected_failure =
739+
'Not all calls occurred\n' ..
740+
'Completed calls:\n' ..
741+
'\tf(1)\n' ..
742+
'Incomplete calls:\n' ..
743+
'\tf()'
744+
745+
should_fail_with_exactly(expected_failure, function()
746+
f:should_be_called_with_any_arguments():
747+
and_then(f:should_be_called_with_any_arguments()):
748+
when(function()
749+
f(1)
750+
end)
751+
end)
752+
end)
736753
end)

src/mach/Expectation.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function expectation:should_be_called_with_any_arguments()
134134
end
135135

136136
self._call_specified = true
137-
table.insert(self._calls, ExpectedCall(self._m, { required = true, ignore_args = true }))
137+
table.insert(self._calls, ExpectedCall(self._m, { required = true, args = table.pack(), ignore_args = true }))
138138
return self
139139
end
140140

0 commit comments

Comments
 (0)