Forked from karnowski/zombie.synchronousChain.coffee
Last active
August 29, 2015 14:02
-
-
Save sirkkalap/6677121eb83d640d34c6 to your computer and use it in GitHub Desktop.
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
vows = require 'vows' | |
zombie = require 'zombie' | |
assert = require 'assert' | |
events = require 'events' | |
promise = require 'promise' | |
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(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