LearnBoost/tobi — pull request #94 by vklap (2014-07-01 20:40:44+00:00)
Title: fix lib/cookie/index.js: when no path specified and req is undefined the...

Hi,

After adding support for cookies and session in express version 4 - my functional tests stopped working.

Bellow are the functional tests + comments with some explanations.

Anyway, thanks for this amazing library.

BR,
Victor
N.B.:
- I'm still a newbie to node.js - so sorry if the code below + my fix don't look good :)
- My functional test with mocha:

var www = require('../../bin/www');
var tobi = require('tobi');
var app = require('../../app');
var browser = tobi.createBrowser(3000, '127.0.0.1');

describe('index', function() {
it ('should get index', function(done) {
// This is the line of code that didn't work - got the following error:
// "TypeError: Cannot read property 'url' of undefined"
browser.get('/', function(res, $) {
res.should.have.status(200);

$('nav.main a:nth-child(1)').should.have.attr('href', '/');
$('nav.main a:nth-child(2)').should.have.attr('href', '/how-it-works');
$('nav.main a:nth-child(3)').should.have.attr('href', '/why');
$('nav.main a:nth-child(4)').should.have.attr('href', '/learn-more');
$('nav.main a:nth-child(5)').should.have.attr('href', '/faq');
$('nav.main a:nth-child(6)').should.have.attr('href', '/register');
$('nav.main a:nth-child(7)').should.have.attr('href', '/login');

$('nav.bottom a:nth-child(1)').should.have.attr('href', '/');
$('nav.bottom a:nth-child(2)').should.have.attr('href', '/faq');
$('nav.bottom a:nth-child(3)').should.have.attr('href', '/register');
$('nav.bottom a:nth-child(4)').should.have.attr('href', '/buy');
$('nav.bottom a:nth-child(5)').should.have.attr('href', '/about-us');
$('nav.bottom a:nth-child(6)').should.have.attr('href', '/contact-us');

$('body').should.have.one('h1', 'Express');
done();
});
});

// I've added this test in order to make sure my fix will work with other url's
it ('should get register page', function(done) {
browser.get('/register', function(res, $) {
res.should.have.status(200);
done();
});
});

});