Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Commit

Permalink
Less verbose console.log.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
assaf committed Nov 20, 2011
1 parent e7d1a78 commit b1bfc13
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 24 deletions.
8 changes: 1 addition & 7 deletions .gitignore
@@ -1,10 +1,4 @@
.npm
build
clean
docs
html
lib
man7
node_modules
build
.lock-wscript
tags
13 changes: 12 additions & 1 deletion 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.

Expand All @@ -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

Expand Down
10 changes: 1 addition & 9 deletions Cakefile
Expand Up @@ -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


Expand Down
24 changes: 19 additions & 5 deletions lib/zombie/index.coffee → 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)
Expand All @@ -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
Expand All @@ -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"
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion spec/browser-spec.coffee
Expand Up @@ -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"
Expand Down

0 comments on commit b1bfc13

Please sign in to comment.