This fixes errors when called_with or returned_with fail if the spy/stub is called with table arguments that are modified after the call to the spy/stub. Similarly, this fixes errors when on_call_with is called with table arguments that are modified after the call to on_call_with.
it("checks called() and called_with() assertions", function()
local s = spy.new(function() end)
local t = { foo = { bar = { "test" } } }
s(1, 2, 3)
s("a", "b", "c")
s(t)
t.foo.bar = "value" -- modify table after call to spy
assert.spy(s).was.called(3)
assert.spy(s).was.called_with(1, 2, 3)
assert.spy(s).was.called_with("a", "b", "c")
assert.spy(s).was.called_with({ foo = { bar = { "test" } } }) -- matches original table
assert.spy(s).was_not.called_with(t) -- does not match modified table
end)
This fixes errors when
called_with
orreturned_with
fail if the spy/stub is called with table arguments that are modified after the call to the spy/stub. Similarly, this fixes errors whenon_call_with
is called with table arguments that are modified after the call toon_call_with
.Note: This is on top of PR #96