Skip to content

Instantly share code, notes, and snippets.

@pzel
Created June 30, 2011 11:10
Show Gist options
  • Save pzel/1056023 to your computer and use it in GitHub Desktop.
Save pzel/1056023 to your computer and use it in GitHub Desktop.
unable to fire event
zombie = require('zombie');
assert = require('assert');
vows = require('vows');
url = "http://localhost:4568/";
// Load the page from localhost
vows.describe('The tags page').addBatch({
'Presence' : {
topic : function() {
//The zombie callback is a function with three args:
// function(error, browser, status){...};
zombie.visit(url + "tags", this.callback);
},
'should be ok': function(e, b, s){
assert.equal(s, "200");
},
'should have the right title': function(e,b,s){
assert.equal(b.text("#header > h1"), "All tags");
}
},
'Adding a new tag': {
topic: function(){
zombie.visit(url+"tags", this.callback);
},
'after submitting tag name': {
topic : function(b) {
b.fill("tag[content]", "holograms").
pressButton("Add tag", this.callback);
},
'it should be successful' : function(b) {
assert.equal(b.response[0], "200");
},
'it should show the new tag' : function(b) {
assert.ok(b.querySelector(".info_for_tag"));
assert.match(b.text(".info_for_tag a"), /\s*holograms\s*/);
},
'after hovering on new tag' : {
topic : function(b) {
// This function does not work *error message below
b.fire("mouseOver", '.info_for_tag');
// This doesn't work either
// b.fire("click", '.info_for_tag a');
b.wait(this.callback);
},
'it should change class' : function(b){
console.log(b.response[2]);
assert.ok(b.querySelector(".unused_tag"));
}
}
}
}
}).export(module);
/* THE ERROR MESSAGE */
♢ The tags page
Presence
✓ should be ok
✓ should have the right title
Adding a new tag after submitting tag name
✓ it should be successful
✓ it should show the new tag
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object .info_for_tag a has no method 'dispatchEvent'
at Browser.fire (/home/p/code/nejiro/node_modules/zombie/lib/zombie/browser.js:173:14)
at Object.<anonymous> (/home/p/code/nejiro/spec/js/ajax_test.js:42:23)
at run (/home/p/code/nejiro/node_modules/vows/lib/vows/suite.js:130:31)
at EventEmitter.<anonymous> (/home/p/code/nejiro/node_modules/vows/lib/vows/suite.js:203:40)
at EventEmitter.emit (events.js:81:20)
at /home/p/code/nejiro/node_modules/vows/lib/vows/context.js:32:52
at /home/p/code/nejiro/node_modules/vows/lib/vows/context.js:46:29
at Browser.<anonymous> (/home/p/code/nejiro/node_modules/zombie/lib/zombie/browser.js:148:18)
at Browser.<anonymous> (/home/p/code/nejiro/node_modules/zombie/lib/zombie/browser.js:9:60)
at Browser.emit (events.js:64:17)
@cjroebuck
Copy link

I'm writing my tests in coffeescript and using vows-bdd to run them, so it's not as tedious as js + vows. Is it possible to test a node.js app from capybara-webkit?

@pzel
Copy link
Author

pzel commented Sep 29, 2011

I think it should be, but you would probably have to write the tests themselves in ruby.

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