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

Commit

Permalink
Added site option allowing you to use visit with a relative path.
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf committed Nov 18, 2011
1 parent 1ff1e00 commit f4fb2ce
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
before_script: "npm install --dev . ; true"
before_script: "npm install . ; true"
script: "npm test"
node:
- 0.4.12
- 0.6.1
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
zombie.js-changelog(7) -- Changelog
===================================

## Version 0.10.3

Added site option allowing you to call `visit` with a relative path.
Example:

browser = new Browser(site: "localhost:3000")
browser.visit("/testing", function(error, browser) {
})

Fixed uploading of attachments to work with Connect/Express (and
possibly other servers). Formidable (used by Connect) does not support
Base64 encoding. Sending binary instead.

Tested on Node 0.6.1.

330 Tests
2.1 sec to complete


### Version 0.10.2 2011-10-13

Fixed #173 browser.open() causes Segmentation fault (Brian McDaniel)
Expand Down
2 changes: 1 addition & 1 deletion Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ runTests = (callback)->
log "Running test suite ...", green
exec "vows --spec spec/*-spec.coffee", (err, stdout, stderr)->
process.stdout.write stdout
process.binding("stdio").writeError stderr
process.stderr.write stderr
callback err if callback
task "test", "Run all tests", ->
runTests (err)->
Expand Down
16 changes: 14 additions & 2 deletions src/zombie/browser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,39 @@ class Browser extends EventEmitter
# Options
# -------

OPTIONS = ["debug", "htmlParser", "loadCSS", "runScripts", "userAgent"]
OPTIONS = ["site", "debug", "htmlParser", "loadCSS", "runScripts", "userAgent"]

# ### debug
#
# True to have Zombie report what it's doing.
@debug = false

# ### htmlParser
#
# Which parser to use (null for default). For example:
# Which parser to use (HTML5 by default). For example:
# zombie.htmlParser = require("html5").HTML5
@htmlParser = null

# ### loadCSS
#
# True to load external stylesheets.
@loadCSS = true

# ### runScripts
#
# Run scripts included in or loaded from the page. Defaults to true.
@runScripts = true

# ### userAgent
#
# User agent string sent to server.
@userAgent = "Mozilla/5.0 Chrome/10.0.613.0 Safari/534.15 Zombie.js/#{exports.version}"

# ### site
#
# You can use visit with a path, and it will make a request relative to this host/URL.
@site = null


# ### withOptions(options, fn)
#
Expand Down Expand Up @@ -353,6 +362,9 @@ class Browser extends EventEmitter
if typeof options is "function"
[callback, options] = [options, null]
@withOptions options, (reset)=>
if site = @site
site = "http://#{site}" unless /^https?:/i.test(site)
url = URL.resolve(site, URL.parse(URL.format(url)))
window.history._assign url
@wait (error, browser)->
reset()
Expand Down

0 comments on commit f4fb2ce

Please sign in to comment.