stefanpenner/ember-app-kit-todos — pull request #18 by WMeldon (2014-03-04 15:45:15+00:00)
Title: [Proof of Concept] Redid Tests to use Mocha, Should and Sinon in lieu of QUnit

#### Pull request for thought, not merging.

A while back I decided to start playing around with the idea of replacing QUnit in EAK with Mocha. I got most of my pieces working but wanted to give the Todos suite a go to get a better handle of the incompatibilities in the new test helpers.

I've managed to get the majority of things working with only minor changes to the test helpers. The biggest core incompatibility was the use of ```module()```, which is a no-go in Node so Mocha doesn't allow it. They use ```suite()``` instead.

Async is still somewhat of an issue, but the [ember-mocha-adapter](https://github.com/teddyzeenny/ember-mocha-adapter) does seem to take care of some of it. I decided to fork the adapter to provide the QUnit style of interface currently in use, but it wasn't in any way a major change.

I still needed to use ```wait()``` on the model tests as the current tests are relying on QUnit specific ```stop() start()``` calls. Mocha doesn't have this capacity so I added ```startApp()``` to the base setup of ```moduleFor()``` to give me access to the function as test helpers are not injected unless you set the app up for testing. There is probably a better approach, but I couldn't entirely wrap my head around it. [Change here](https://github.com/WMeldon/ember-app-kit-todos/commit/6218d9690f2c0250b4ad051724bcadb6a6035762).

I converted all of the assertions to [Should.js](https://github.com/visionmedia/should.js/), but it's not entirely necessary as Mocha is relatively assertion agnostic.

The other big thing I tried to get working was implementing method spies/stubs/mocks with [Sinon.js](http://sinonjs.org/). The old approach was to set an expected number of assertions at the top and then stub out functions that most just made obvious statements (```ok(true)```), but Mocha doesn't have assertion counting so I had to do things a little differently.. The difference is probably best seen [here](https://github.com/WMeldon/ember-app-kit-todos/commit/629c9be7603a7d0d175ccc560d76133247cb5433#diff-68018ebd722ec2d6c980b93edaaddd9bR123).

There is definitely a lot here, but I want to drop this off for perusal because I brought it up many moons ago with https://github.com/stefanpenner/ember-app-kit/issues/415. Given the state of EAK, I don't think there is any possible way to integrate much of what I've done here, but with the Ember-CLI, I figure there could be some possibility of making Mocha an option when creating a new project.

There is still work to be done in the Async department I think, but if anyone was curious as to what changes would need to be made to put Mocha in Ember App Kit, here's a starting point.

I'm very much not suggesting that this be merged, but if anyone has any improvements, they are more than welcome. I'm very new to most of this.