Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Add test harness to dispatch #6

pacovell opened this Issue · 0 comments

1 participant

Paul Covell
Paul Covell

I've added a test harness to my production code that needs to be re-integrated into dispatch:

It relies on the controllers.js lib file, which may also be reasonable to integrate into dispatch:

It gets used together with sinon.js in a controller vows test like this:

var Asks = new ControlChain('asks');

function mockFindUser(user) {
    return function () {
        models.User.findById = function (id, callback) {
            callback(null, user);
        sinon.spy(models.User, 'findById');

vows.describe('Ask Controller').addBatch({
    'my, user logged in' : {
        topic : Asks.get('my', { session : { currentUserId : '123456789abc' } },
            { before : [ mockFindUser(mockObjects.user), mockFindAsks() ] }),
        'finds user' : function (err, req, res) {
            assert.equal(, models.User.findById.getCall(0).args[0]);
        'finds asks' : function (err, req, res) {
        'should have status OK' : function (err, req, res) {
            assert.equal(res.statusCode, 200);
        'should have correct return value' : function (err, req, res) {
            assert.deepEqual(mockObjects.asks, JSON.parse(res.body));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.