Closed jbbjarnason closed 3 years ago
see also: Olivine-Labs/busted#578
According to the busted issue, this could be solved somewhere here: https://github.com/Olivine-Labs/luassert/blob/b8fb59ac1eb1a2d59793ee1707ac42f979438e8f/src/spy.lua#L54
I've made an attempt to address this issue over in qha/luassert format-called-returned-with-args.
The formatting of passed in and expected args/return values is absolutely abysmal though (see the output from the four new failing tests in spec/spies_spec.lua).
The first reason is that the top level list is rendered as a table which is not particularly helpful. I presume this should be addressed by adding a formatter but i don't know how it should be kept from firing on too many tables (any table with integer keys and "n" seems way to wide).
The second reason is that matchers are rendered as tables. This too should probably be addressed with a formatter but again i need some tips. Could one compare with namespace.matcher[name] to identify appropriate targets? Is there any way to get to the matcher arguments?
For both of these formatters it seems they may not be desirable at all times, would it make sense to try to register them only during arguments/return value formatting?
Is there any way to get to the matcher arguments?
Short of changing the matcher interface to return something like:
setmetatable({ arguments = arguments }, { __call = function(_, value) ... end, })
I think i figured out the answers to my questions above, please see: #165
pr was merged
When using assert spy to check function call with defined arguments, a wrong argument is not displayed. Test example:
The following error is displayed: