We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c3bddb8 commit fd3a517Copy full SHA for fd3a517
spec/mach_spec.lua
@@ -750,4 +750,10 @@ describe('The mach library', function()
750
end)
751
752
753
+
754
+ it('should give a helpful error message if a non-existent expectation is used', function()
755
+ should_fail_with("attempt to call a nil value (field 'should_be_call')", function()
756
+ f:should_be_call()
757
+ end)
758
759
src/mach.lua
@@ -33,6 +33,9 @@ end
33
local function create_expectation(_, method)
34
return function(self, ...)
35
local expectation = Expectation(handle_mock_calls, self)
36
+ if not expectation[method] then
37
+ error("attempt to call a nil value (field '" .. method .. "')", 2)
38
+ end
39
return expectation[method](expectation, ...)
40
end
41
0 commit comments