Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

This patch fixes the fact that Resources toString throws errors #228

Closed
wants to merge 2 commits into from

2 participants

@bunnymatic

We were trying to check the page's resource list and noticed that the newer (after 0.11.3 i think) versions throw errors when calling resources.toString.

I've submitted a very simple fix here, and a new spec for resources. We'd love to get this into master so we don't have to refer to our own fork of the project.

I'm new to coffee and vows. Hopefully, the structure of the new spec is acceptable.

Cheers
Jon Rogers

@assaf assaf closed this in da2dff3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 14, 2011
  1. @bunnymatic
Commits on Dec 15, 2011
  1. @bunnymatic
This page is out of date. Refresh to see the latest.
View
1  lib/zombie/resources.coffee
@@ -18,6 +18,7 @@ URL = require("url")
partial = (text, length = 250)->
+ return '' if !text
return text if text.length <= length
return text.substring(0, length - 3) + "..."
indent = (text)->
View
2  package.json
@@ -1,5 +1,5 @@
{ "name": "zombie",
- "version": "0.12.3",
+ "version": "0.12.3-2rye",
"description": "Insanely fast, full-stack, headless browser testing using Node.js",
"homepage": "http://zombie.labnotes.org/",
"author": "Assaf Arkin <assaf@labnotes.org> (http://labnotes.org/)",
View
3  spec/browser_spec.coffee
@@ -69,6 +69,9 @@ vows.describe("Browser").addBatch(
assert.lengthOf errors, 0
"should reset browser errors": (_, browser, status, errors)->
assert.lengthOf browser.errors, 0
+ "should have a resources object": (browser)->
+ assert.ok browser.resources
+
"with error":
topic: ->
View
47 spec/resources_spec.coffee
@@ -0,0 +1,47 @@
+{ vows: vows, assert: assert, brains: brains, Zombie: Zombie, Browser: Browser } = require("./helpers")
+JSDOM = require("jsdom")
+
+
+vows.describe("Resources").addBatch(
+
+ "browsing":
+ topic: ->
+ brains.get "/browser/scripted", (req, res)->
+ res.send """
+ <html>
+ <head>
+ <title>Whatever</title>
+ <script src="/jquery.js"></script>
+ </head>
+ <body>Hello World</body>
+ <script>
+ document.title = "Nice";
+ $(function() { $("title").text("Awesome") })
+ </script>
+ <script type="text/x-do-not-parse">
+ <p>this is not valid JavaScript</p>
+ </script>
+ </html>
+ """
+
+ "resources":
+ topic: ->
+ brains.ready =>
+ browser = new Browser
+ browser.visit "http://localhost:3003/browser/scripted", @callback
+ "should exist on the browser": (browser)->
+ assert.ok browser.resources
+ "should have a length": (browser)->
+ assert.equal browser.resources.length, 2
+ "should include jquery": (browser)->
+ assert.equal browser.resources[1].url, "http://localhost:3003/jquery-1.7.1.js"
+ "should include the 'self' url": (browser)->
+ assert.equal browser.resources[0].url, "http://localhost:3003/browser/scripted"
+ "should have a 'dump' method": (browser)->
+ try
+ browser.resources.toString();
+ catch e
+ assert.ok false, "calling dump method throws an error [" + e + "]"
+
+
+).export(module)
Something went wrong with that request. Please try again.