Jasmine: Why is my assert not executed in my callback

Problem

I am using Jasmine to test some code. Everything works fine, except for the last assert. Can someone help me out?

var mongoose = require("mongoose")
  , db = mongoose.connect('mongodb://localhost/database')
  , Schema = mongoose.Schema;;


describe('Lockmanager', function() {

  var status;

  var Test = new Schema({
    name: String
  });
  var testModel = mongoose.model('Test', Test);
  var LockManager = require('locks').buildLockManager().getManager(testModel, 10000);

  var newTestModel = new testModel({
    name: "Test"
  });

  it('should set a lock on an arbitrary mongoose model', function() {

    this.after(function() {
      testModel.remove({}, function(err, numAffected) {
        status = 'collectionRemoved';
      });
    });

    runs(function() {
      newTestModel.save(function(err) {
        expect(err).toBeNull();
        status = 'hasBeenSaved';
      });
    });
    waitsFor(function() {
      return status == 'hasBeenSaved';
    });

    runs(function() {
      LockManager.requestLock(newTestModel._id, function(err, response) {
        expect(err).toBeNull();
        status = 'readyToBeReleased';
      });
    });
    waitsFor(function() {
      return status == 'readyToBeReleased';
    });

    runs(function() {
      LockManager.releaseLock(newTestModel._id, function(err) {
        expect(err).toBeNull();
        status = 'readyToBeDeleted';
      });
    });

    waitsFor(function() {
      return status == 'readyToBeDeleted';
    })

  });

  it('should delete all test entries after the test', function() {

    waitsFor(function() {
      return status == 'collectionRemoved';
    });

    runs(function() {
      testModel.find({}, function(err, res) {
        expect(res.length).toEqual(0);
        status = 'allDone';
      });
    });

    /*** This waitsFor fixed the problem ***/
    waitsFor(function() {
      return status == 'allDone';
    });

  });

});

The resulting log is this:

jasmine-node spec/lockmanager.spec.js Lock for '4fabcae0b563859269000001' has been acquired. .Released lock for '4fabcae0b563859269000001'. .

Finished in 0.031 seconds 2 tests, 3 assertions, 0 failures

This has been executed.

Problem courtesy of: Joseph Tura

Solution

Turns out I needed another 'waitsFor' after the last 'runs' to make sure the assert was fully executed before the results were shown. Oh, and newTestModel should have been testModel in the after-function.

Modified code in the original question.

Solution courtesy of: Joseph Tura

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.