diff --git a/.gitignore b/.gitignore index 77f5bd934..c12a6462e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,4 @@ -.npm -build -clean +docs html -lib man7 node_modules -build -.lock-wscript -tags diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ee5ba345..e68690f1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ zombie.js-changelog(7) -- Changelog =================================== -## Version 0.11.0 2011-11-18 +## Version 0.11.0 2011-11-19 Changed error handling for the better. @@ -13,6 +13,17 @@ Instead, an array of errors is passed as the fourth argument. You can also access `browser.errors` and to get just the last one, e.g. to check if any errors were reported, use `browser.error`. + +Using `console.log(browser)` will puke over your terminal, so we add +global defaults for sanity. + +Set `console.depth` to specify how many times to recurse while +formatting the object (default is zero). + +Set `console.showHidden` to show non-enumerable properties (defaults to +false). + + 333 Tests 1.7 sec to complete diff --git a/Cakefile b/Cakefile index a899df94e..0ae980cb5 100644 --- a/Cakefile +++ b/Cakefile @@ -59,16 +59,8 @@ task "install", "Install Zombie in your local repository", -> onerror err -## Building ## - -task "watch", "Continously compile CoffeeScript to JavaScript", -> - cmd = spawn("coffee", ["-cw", "-o", "lib"]) - cmd.stdout.on "data", (data)-> process.stdout.write green + data + reset - cmd.on "error", onerror - - clean = (callback)-> - exec "rm -rf lib build html man7", callback + exec "rm -rf build html man7", callback task "clean", "Remove temporary files and such", -> clean onerror diff --git a/lib/zombie/index.coffee b/lib/zombie.coffee similarity index 57% rename from lib/zombie/index.coffee rename to lib/zombie.coffee index c40e91252..a3ab8874b 100644 --- a/lib/zombie/index.coffee +++ b/lib/zombie.coffee @@ -1,9 +1,10 @@ -zombie = require("./browser") +Zombie = require("./zombie/browser") +Sys = require("sys") # Constructor for a new Browser. Takes no arguments. -exports.Browser = zombie.Browser -exports.package = zombie.package -exports.version = zombie.version +exports.Browser = Browser = Zombie.Browser +exports.package = Zombie.package +exports.version = Zombie.version # ### zombie.visit(url, callback) @@ -27,7 +28,7 @@ exports.version = zombie.version # * options -- Initialize the browser with these options # * callback -- Called with error, browser exports.visit = (url, options, callback)-> - new zombie.Browser(options).visit(url, options, callback) + new Browser(options).visit(url, options, callback) # ### listen port, callback @@ -39,3 +40,16 @@ exports.visit = (url, options, callback)-> # invoked once Zombie is ready to accept new connections. exports.listen = (port, callback)-> require("./protocol").listen(port, callback) + + +# console.log(browser) pukes over the terminal, so we apply some sane +# defaults. You can override these: +# console.depth - How many time to recurse while formatting the +# object (default to zero) +# console.showHidden - True to show non-enumerable properties (defaults +# to false) +console.depth = 0 +console.showHidden = false +console.log = -> + formatted = ((if typeof arg == "string" then arg else Sys.inspect(arg, console.showHidden, console.depth)) for arg in arguments) + process.stdout.write formatted.join(" ") + "\n" diff --git a/package.json b/package.json index b670e9954..26bd7aeab 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ ], "keywords": [ "test", "tests", "testing", "TDD", "spec", "specs", "BDD", "headless", "browser", "html", "html5", "dom", "css", "javascript", "integration", "ajax", "full-stack", "DSL" ], - "main": "lib/zombie/index.coffee", + "main": "lib/zombie", "directories": { "doc": "./doc", "lib": "./lib", diff --git a/spec/browser-spec.coffee b/spec/browser-spec.coffee index a59521b54..d6ea17572 100644 --- a/spec/browser-spec.coffee +++ b/spec/browser-spec.coffee @@ -100,7 +100,8 @@ vows.describe("Browser").addBatch( browser.on "done", (browser)=> @callback null, browser browser.window.location = "http://localhost:3003/browser/scripted" browser.wait() - "should fire done event": (browser)-> assert.ok browser.visit + "should fire done event": (browser)-> + assert.ok browser.visit "source": zombie.wants "http://localhost:3003/browser/scripted"