{"action":"opened","issue":{"url":"https://api.github.com/repos/cjohansen/Sinon.JS/issues/664","labels_url":"https://api.github.com/repos/cjohansen/Sinon.JS/issues/664/labels{/name}","comments_url":"https://api.github.com/repos/cjohansen/Sinon.JS/issues/664/comments","events_url":"https://api.github.com/repos/cjohansen/Sinon.JS/issues/664/events","html_url":"https://github.com/cjohansen/Sinon.JS/issues/664","id":55826790,"number":664,"title":"stub a module which is a function?","user":{"login":"kevinburke","id":234019,"avatar_url":"https://avatars.githubusercontent.com/u/234019?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinburke","html_url":"https://github.com/kevinburke","followers_url":"https://api.github.com/users/kevinburke/followers","following_url":"https://api.github.com/users/kevinburke/following{/other_user}","gists_url":"https://api.github.com/users/kevinburke/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinburke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinburke/subscriptions","organizations_url":"https://api.github.com/users/kevinburke/orgs","repos_url":"https://api.github.com/users/kevinburke/repos","events_url":"https://api.github.com/users/kevinburke/events{/privacy}","received_events_url":"https://api.github.com/users/kevinburke/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-28T22:38:28Z","updated_at":"2015-01-28T22:38:28Z","closed_at":null,"body":"say I have something like\r\n\r\n##### hardwork.js\r\n\r\n```javascript\r\nmodule.exports = function(req, res, next) {\r\n     // do some work\r\n     next()\r\n}\r\n```\r\n\r\nI want to stub this function directly. Something like\r\n\r\n```javascript\r\nhardwork = require('./hardwork');\r\n\r\nsinon.spy(hardwork, function(req, res, next) { next() });\r\n```\r\n\r\nIs there a way to do this? I read through the documentation, but it seems way more geared to stubbing methods on objects. Unfortunately in this case it's not straightforward to make the function a method on an object.\r\n\r\n\r\n\r\n"}}