Hello Frank,
I'm currently building all my tests with mocha, but mostly through HTTP like you.
But just for testing and exploring, I created a dummy before() action in my test case and my models are directly accessible.
Maybe my code is a bit different. I will post it here, maybe it helps you:
var app = require('../server'),
tobi = require('tobi'),
browser = tobi.createBrowser(3001, '127.0.0.1');
app.listen(3001)
describe('GET /books *', function() {
// dummy before action to test accessibility of defined models
before(function(done) {
// also Book.all() works
app.models.Book.all({where: {name: 'Game of Throne'}}, function(err, result) {
if(!result || (result && result.length == 0)) {
Book.find(1, function(err, b) {
b.updateAttribute('name', 'Game of Throne', function(err, result) {
done()
});
})
}
});
});
it('should validate the page elements', function(done) {
browser.get('/books', function(res, $){
res.should.have.status(200);
$('title').should.have.text('Books:Books index');
$('h1').should.have.text('My Books');
$('a.btn.btn-primary').should.have.text(' Add Book');
// hint: use css not() selector because it would match the delete button too
$('a[href="/books/1"]:not([data-remote])').should.have.text('Game of Thrones');
done();
});
});
});
/ end code example
Regards,
Andreas