{"action":"created","issue":{"url":"https://api.github.com/repos/Olivine-Labs/luassert/issues/129","labels_url":"https://api.github.com/repos/Olivine-Labs/luassert/issues/129/labels{/name}","comments_url":"https://api.github.com/repos/Olivine-Labs/luassert/issues/129/comments","events_url":"https://api.github.com/repos/Olivine-Labs/luassert/issues/129/events","html_url":"https://github.com/Olivine-Labs/luassert/issues/129","id":97897320,"number":129,"title":"assert.spy.was.called_with() should have variants just check equality.","user":{"login":"xpol","id":20248,"avatar_url":"https://avatars.githubusercontent.com/u/20248?v=3","gravatar_id":"","url":"https://api.github.com/users/xpol","html_url":"https://github.com/xpol","followers_url":"https://api.github.com/users/xpol/followers","following_url":"https://api.github.com/users/xpol/following{/other_user}","gists_url":"https://api.github.com/users/xpol/gists{/gist_id}","starred_url":"https://api.github.com/users/xpol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xpol/subscriptions","organizations_url":"https://api.github.com/users/xpol/orgs","repos_url":"https://api.github.com/users/xpol/repos","events_url":"https://api.github.com/users/xpol/events{/privacy}","received_events_url":"https://api.github.com/users/xpol/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-29T09:36:57Z","updated_at":"2015-07-31T08:26:32Z","closed_at":null,"body":"Lets see and example:\r\n\r\n```lua\r\nlocal Foo = {}\r\nfunction Foo:add(Bar)\r\n  Bar.callback(self)\r\n  self.bar = Bar\r\nend\r\n\r\nlocal Bar = {}\r\nfunction Bar.callback() end\r\n\r\ndescribe('Foo', function()\r\n  it(':add() calls Bar.callback()', function()\r\n    local s = spy.on(Bar, 'callback')\r\n    Foo:add(Bar) -- make a deep copy of Foo, before Foo.bar sets to Bar\r\n    assert.spy(s).was.called(1) -- OK\r\n    assert.spy(s).was.called_with(Foo) -- Failure, because Foo modified after callback...\r\n  end)\r\nend)\r\n```\r\n\r\n1. The Foo:add() calls the spy and spy make a deep copy of Foo as FooCopy\r\n2. Then Foo:add() modifies Foo by add a Foo.bar = Bar\r\n3. The `assert.spy(s).was.called_with(Foo)` Failure because the `Foo` was not same as `FooCopy`.\r\n\r\nSo, I think it is needs that we have option in `spy` or `called_with` just keep a reference to its calling args and compare args by `==` (or something else)."},"comment":{"url":"https://api.github.com/repos/Olivine-Labs/luassert/issues/comments/126606674","html_url":"https://github.com/Olivine-Labs/luassert/issues/129#issuecomment-126606674","issue_url":"https://api.github.com/repos/Olivine-Labs/luassert/issues/129","id":126606674,"user":{"login":"xpol","id":20248,"avatar_url":"https://avatars.githubusercontent.com/u/20248?v=3","gravatar_id":"","url":"https://api.github.com/users/xpol","html_url":"https://github.com/xpol","followers_url":"https://api.github.com/users/xpol/followers","following_url":"https://api.github.com/users/xpol/following{/other_user}","gists_url":"https://api.github.com/users/xpol/gists{/gist_id}","starred_url":"https://api.github.com/users/xpol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xpol/subscriptions","organizations_url":"https://api.github.com/users/xpol/orgs","repos_url":"https://api.github.com/users/xpol/repos","events_url":"https://api.github.com/users/xpol/events{/privacy}","received_events_url":"https://api.github.com/users/xpol/received_events","type":"User","site_admin":false},"created_at":"2015-07-31T08:26:32Z","updated_at":"2015-07-31T08:26:32Z","body":"@o-lim Thank you very much!"}}