Skip to content

Instantly share code, notes, and snippets.

@cpsubrian
Created August 1, 2011 01:58
Show Gist options
  • Save cpsubrian/1117455 to your computer and use it in GitHub Desktop.
Save cpsubrian/1117455 to your computer and use it in GitHub Desktop.
Using tobi with vows.
var vows = require('vows')
, tobi = require('tobi')
, port = 80
, host = 'www.google.com';
/**
* Topic macro to GET a url.
*/
var getUrl = function(url) {
return function() {
var browser = tobi.createBrowser(port, host);
browser.get(url, this.callback.bind(this, null));
}
}
/**
* Sample test.
*/
vows.describe('Tobi Test').addBatch({
'A request to the frontpage of google': {
topic: getUrl('/'),
'should have a status of 200': function(_, res, $){
res.should.have.status(200);
},
'should have an image with alt="Google"': function(_, res, $) {
$('img[alt="Google"]').should.exist;
}
}
}).export(module);
@cpsubrian
Copy link
Author

Probably should be $('img[alt="Google"]').length.should.be.equal(1); or something. I haven't been using vows or tobi lately, but I'm glad people are still finding this example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment