Created
April 15, 2011 18:18
-
-
Save karnowski/922180 to your computer and use it in GitHub Desktop.
Zombie.js + Vows: Capybara-like synchronous chain example
This file contains hidden or 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
# ... require zombie, vows, etc. ... | |
events = require("events") | |
zombie.synchronousChain = (browser, steps)-> | |
promise = new(events.EventEmitter) | |
zombie._linkInTheChain(promise, browser, steps) | |
promise | |
zombie._linkInTheChain = (promise, browser, steps)-> | |
step = steps.shift() | |
if step? | |
step(browser) | |
browser.wait ()-> | |
zombie._linkInTheChain(promise, browser, steps) | |
else | |
promise.emit('success', browser) | |
emptyCallback = ()-> null | |
suite = vows.describe("Searching by Vehicle: Handling Bad ZIP Codes") | |
suite.browser = new zombie.Browser(debug: false) | |
suite.addBatch "when we walk through the vehicle search form and give an invalid ZIP code": | |
topic: ()-> | |
zombie.synchronousChain @suite.browser, [ | |
(b)-> b.visit("http://localhost:3000/widget/") | |
(b)-> b.select("vehicle-year", "2009") | |
(b)-> b.select("vehicle-make", "Ford") | |
(b)-> b.select("vehicle-model", "Mustang") | |
(b)-> b.select("vehicle-option", "V6 Premium w/Pony Pkg. (Coupe & Convertible)") | |
(b)-> b.fill("vehicle-zip", "junkjunkjunk") | |
(b)-> b.pressButton "search-vehicles", emptyCallback | |
] | |
"displays messages that ....": (err, b)-> | |
results = b.html("#search-results-container") | |
# ... do some assertions ... | |
suite.export(module) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On line 24, at least when using "zombie": "^2.0.0-alpha31" I needed to do:
https://gist.github.com/sirkkalap/6677121eb83d640d34c6#file-zombie-synchronouschain-coffee-L26