mfncooper/mockery — pull request #6 by amallavarapu (2012-03-12 07:00:33+00:00)
Title: Fixes a problem involving the node module cache

A number of people are having trouble using mockery because previous tests leave modules in the node module cache which may contain references to mocked modules. The presence of these mocked modules then breaks subsequent tests.
https://groups.google.com/forum/#!topic/nodejs/AioYD0tlmjo/discussion

There is currently no way to clear the node cache due to a bug in mocker.js. It turns out that the line:

```javascript
file = m._resolveFilename(request, parent)[1];
```

is the problem. Instead of returning the resolved filename, the [1] returns the second character of the returned filename.

I have fixed this bug, and added a couple of functions that I find very helpful for integration testing where MANY modules are included. In this case, it's really tedious to registerAllowable all the many modules that happen to get included during a load. For this purpose, I added:

function registerAllAllowableStart(unhook) {...}
function registerAllAllowableEnd() {...}

I've added documentation for these functions in the README.

Thanks for making mockery! We're finding it really useful.

Cheers,

Aneil