Closed Tieske closed 11 years ago
What about tables with meta indexes that can be called as functions?
I'd say that it is up to the user to spy on the __call metamethod instead of on the table. Possibly a future enhancement.
I'd say that it is up to the user to spy on the __call metamethod instead of on the table
That does not seem very user friendly. Conceivably you might spy on external code when verifying interactions, and then you have to worry about the implementation of that code? Besides, checking for __call is trivial, so why not do that?
updated it, realized that spying on __call would not only spy on an individual object but spy on all objects sharing that same metatable. That could make testing harder, so added it.
PS. busted documentation should be updated for spy example;
local s = spy.new()
should become local s = spy.new(function() end)
Looks awesome - although I'll follow up so you can run spy.new
with no arguments to create a generic function spy without having to duplicate (function() end)
often. I'll check for no arguments rather than a nil argument specifically so that we can still throw errors if you pass in something that shouldn't be nil.
Looks awesome - although I'll follow up so you can run
spy.new
with no arguments to create a generic function spy without having to duplicate(function() end)
often. I'll check for no arguments rather than a nil argument specifically so that we can still throw errors if you pass in something that shouldn't be nil.
That would be creating a stub. So instead of spy.new(function() end)
it should be stub.new()
to create a 'blank' spy.
... functions as values to spy on.