teddyzeenny/ember-mocha-adapter — pull request #2 by slindberg (2013-06-26 20:02:52+00:00)
Title: Preserve context when invoking hooks/tests

This allows attaching test-related objects to the mocha test context, e.g. stubs, mock servers, etc. (mostly used in unit tests).

```javascript
describe("User export", function() {
beforeEach(function() {
this.sinon = sinon.sandbox.create();
this.server = this.sinon.useFakeServer();
});

afterEach(function() {
this.sinon.restore();
});

it("should make an AJAX request and resolve the returned promise if successful", function() {
var spy = this.sinon.spy();
Ember.run(this, function() {
App.User.export.then(spy);
this.server.respond();
});

expect(spy).to.have.been.called;
});
});