{"action":"created","issue":{"url":"https://api.github.com/repos/jasmine/jasmine/issues/737","labels_url":"https://api.github.com/repos/jasmine/jasmine/issues/737/labels{/name}","comments_url":"https://api.github.com/repos/jasmine/jasmine/issues/737/comments","events_url":"https://api.github.com/repos/jasmine/jasmine/issues/737/events","html_url":"https://github.com/jasmine/jasmine/issues/737","id":53994050,"number":737,"title":"SpyRegistry clearSpies() puts inherited methods onto target prototype","user":{"login":"coderagebbc","id":8493639,"avatar_url":"https://avatars.githubusercontent.com/u/8493639?v=3","gravatar_id":"","url":"https://api.github.com/users/coderagebbc","html_url":"https://github.com/coderagebbc","followers_url":"https://api.github.com/users/coderagebbc/followers","following_url":"https://api.github.com/users/coderagebbc/following{/other_user}","gists_url":"https://api.github.com/users/coderagebbc/gists{/gist_id}","starred_url":"https://api.github.com/users/coderagebbc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coderagebbc/subscriptions","organizations_url":"https://api.github.com/users/coderagebbc/orgs","repos_url":"https://api.github.com/users/coderagebbc/repos","events_url":"https://api.github.com/users/coderagebbc/events{/privacy}","received_events_url":"https://api.github.com/users/coderagebbc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-11T15:04:20Z","updated_at":"2015-01-12T20:05:27Z","closed_at":null,"body":"One of the issues we're having migrating tests from JSTestDriver with sinon to with Jasmine is that we cannot run our tests in a randomised order.\r\n\r\nThis is rooted in the use of inheritance and the way in which Jasmine returns spied on function back to their original values (I don't want to get into a debate on composition over inheritance at this stage, I probably agree with you).\r\n\r\nWhat happens is when we have a function on the prototype that comes from a superclass n levels up (we're currently using a variant of resig's Class()), jasmine takes a copy of the original based on it as being a member of the subclass. https://github.com/jasmine/jasmine/blob/master/src/core/base.js#L60\r\n\r\nIn clearSpies() it returns the value back onto the subclass - \r\nhttps://github.com/jasmine/jasmine/blob/master/src/core/SpyRegistry.js#L43\r\n\r\nThis unfortunately hides the superclass behaviour which is breaking our other tests when not run in specific orders.\r\n\r\nThere are three possible solutions to this.\r\n1. Check for hasOwnProperty when creating the spy and throw an exception when the property does not exist.\r\n2. return the function back to the superclass only\r\n3. do nothing.\r\n\r\nI have potential solutions for 1 and 2 and wonder what the community thinks is the best approach before I put in a PR.\r\n\r\noption 3 suggests this is not really a problem - and I'd be interested in hearing arguments as to whyu this is the case. Genuinely,\r\n\r\nRich\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/jasmine/jasmine/issues/comments/69635950","html_url":"https://github.com/jasmine/jasmine/issues/737#issuecomment-69635950","issue_url":"https://api.github.com/repos/jasmine/jasmine/issues/737","id":69635950,"user":{"login":"slackersoft","id":512724,"avatar_url":"https://avatars.githubusercontent.com/u/512724?v=3","gravatar_id":"","url":"https://api.github.com/users/slackersoft","html_url":"https://github.com/slackersoft","followers_url":"https://api.github.com/users/slackersoft/followers","following_url":"https://api.github.com/users/slackersoft/following{/other_user}","gists_url":"https://api.github.com/users/slackersoft/gists{/gist_id}","starred_url":"https://api.github.com/users/slackersoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slackersoft/subscriptions","organizations_url":"https://api.github.com/users/slackersoft/orgs","repos_url":"https://api.github.com/users/slackersoft/repos","events_url":"https://api.github.com/users/slackersoft/events{/privacy}","received_events_url":"https://api.github.com/users/slackersoft/received_events","type":"User","site_admin":false},"created_at":"2015-01-12T20:05:27Z","updated_at":"2015-01-12T20:05:27Z","body":"I'm not totally sure I understand what exactly is happening. It sounds like you're getting a function from the parent prototype put into the child prototype, but that doesn't seem like it would cause an issue. "}}