Created
August 1, 2011 01:58
-
-
Save cpsubrian/1117455 to your computer and use it in GitHub Desktop.
Using tobi with vows.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
✗ should have a status of 200
» expected { external: undefined,
history: [ '/' ],
cookieJar: { cookies: [] },
followRedirects: true,
port: 80,
host: 'www.google.com',
https: false } to have a property 'statusCode' // should.js:474
Just tried it with tobi 0.3.1 and vows 0.5.8 and it worked fine. I haven't had a ton of time to play with node lately so those might be out of date.
Found my problem; working in coffeescript and topic implicit return was burning me.
FYI I can run the example above changing host to be any site and the following vow:
$('img[alt="Google"]').should.exist;
Is still true from this gist, though there's no such image on the page and the selector returns nothing when run from the inspector.
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
What versions are you using, this example no longer works for me?