o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1358449145.652717: @value"–{I" class:EFI"ProcessedAsset;FI"logical_path;FI"$teabag/phantomjs/runner_spec.js;FI" pathname;FI"Z/Users/jejacks0n/Projects/teabag/spec/javascripts/teabag/phantomjs/runner_spec.coffee;FI"content_type;FI"application/javascript;FI" mtime;FI"2013-01-01T20:41:02-07:00;FI" length;FiSI" digest;F"%b63767f86b8e688f02b562048a694b17I" source;FI"S(function() { window.phantom = { exit: function() {} }; window.require = function(file) { switch (file) { case "system": return { args: ["runner.coffee", "http://host:port/path", "200"] }; case "webpage": return { create: function() { return { open: function() { return {}; }, evaluate: function() { return {}; } }; } }; } }; describe("PhantomJS Runner", function() { beforeEach(function() { this.logSpy = spyOn(window.console, "log"); return this.runner = new Runner(); }); describe("constructor", function() { it("sets the url from system.args", function() { return expect(this.runner.url).toBe("http://host:port/path"); }); return it("sets the timeout from system.args", function() { return expect(this.runner.timeout).toBe(200 * 1000); }); }); describe("#run", function() { beforeEach(function() { this.initSpy = spyOn(this.runner, "initPage"); return this.loadSpy = spyOn(this.runner, "loadPage"); }); it("calls initPage", function() { this.runner.run(); return expect(this.initSpy).toHaveBeenCalled(); }); return it("calls loadPage", function() { this.runner.run(); return expect(this.loadSpy).toHaveBeenCalled(); }); }); describe("#initPage", function() { return it("creates a webpage and assigns it to @page", function() { this.runner.initPage(); return expect(typeof this.runner.page["open"]).toBe("function"); }); }); describe("#loadPage", function() { beforeEach(function() { return this.runner.initPage(); }); it("opens the url in the page", function() { var spy; spy = spyOn(this.runner.page, "open"); this.runner.loadPage(); return expect(spy).toHaveBeenCalledWith(this.runner.url); }); return it("attaches all the methods to page", function() { spyOn(this.runner, "pageCallbacks").andCallFake(function() { return { callback1: "method1", callback2: "method2" }; }); this.runner.loadPage(); expect(this.runner.page.callback1).toBe("method1"); return expect(this.runner.page.callback2).toBe("method2"); }); }); describe("#waitForResults", function() { beforeEach(function() { this.timeoutSpy = spyOn(window, "setTimeout"); return this.runner.initPage(); }); it("evaluates in the context of the page", function() { var spy; spy = spyOn(this.runner.page, "evaluate").andReturn(false); this.runner.waitForResults(); return expect(spy).toHaveBeenCalled(); }); it("sets a timeout of 100ms if not finished", function() { spyOn(this.runner.page, "evaluate").andReturn(false); this.runner.waitForResults(); return expect(this.timeoutSpy).toHaveBeenCalled(); }); return it("calls finish if Teabag says that it's finished", function() { var spy; spyOn(this.runner.page, "evaluate").andCallFake(function(f) { return f(); }); spy = spyOn(this.runner, "finish"); window.Teabag.finished = true; this.runner.waitForResults(); return expect(spy).toHaveBeenCalled(); }); }); describe("#fail", function() { it("logs the error message", function() { this.runner.fail("_message_"); expect(this.logSpy).toHaveBeenCalledWith("Error: _message_"); return expect(this.logSpy).toHaveBeenCalledWith('{"_teabag":true,"type":"exception"}'); }); return it("exits with the error code", function() { var spy; spy = spyOn(phantom, "exit"); this.runner.fail("_message_", 2); return expect(spy).toHaveBeenCalledWith(2); }); }); describe("#finish", function() { it("logs an empty string (to fix line feeds in the console)", function() { this.runner.finish(); return expect(this.logSpy).toHaveBeenCalledWith(" "); }); return it("calls exit with a success code", function() { var spy; spy = spyOn(phantom, "exit"); this.runner.finish(); return expect(spy).toHaveBeenCalledWith(0); }); }); describe("#pageCallbacks", function() { return it("returns an object with the expected methods", function() { var object; if (!Object.keys) { return; } object = this.runner.pageCallbacks(); return expect(Object.keys(object)).toEqual(["onError", "onConsoleMessage", "onLoadFinished"]); }); }); return describe("callback method", function() { beforeEach(function() { return this.callbacks = this.runner.pageCallbacks(); }); describe("#onError", function() { return it("logs the json of a message and trace", function() { this.callbacks.onError("_message_", ["trace1", "trace2"]); return expect(this.logSpy).toHaveBeenCalledWith('{"_teabag":true,"type":"error","message":"_message_","trace":["trace1","trace2"]}'); }); }); describe("#onConsoleMessage", function() { return it("logs the message", function() { this.callbacks.onConsoleMessage("_message_"); return expect(this.logSpy).toHaveBeenCalledWith("_message_"); }); }); return describe("#onLoadFinish", function() { beforeEach(function() { this.runner.initPage(); return this.waitSpy = spyOn(this.runner, "waitForResults"); }); it("fails if the status was not success", function() { var evalSpy, spy; spy = spyOn(this.runner, "fail"); evalSpy = spyOn(this.runner.page, "evaluate").andReturn(true); this.callbacks.onLoadFinished("failure"); expect(spy).toHaveBeenCalledWith("Failed to load: " + this.runner.url); expect(evalSpy).toHaveBeenCalled(); return expect(this.waitSpy).wasNotCalled(); }); return it("calls waitForResults", function() { this.callbacks.onLoadFinished("success"); return expect(this.waitSpy).toHaveBeenCalled(); }); }); }); }); }).call(this); ;TI"dependency_digest;F"%fd97a62634a35fddc0dc5e791b391e9cI"required_paths;F[I"Z/Users/jejacks0n/Projects/teabag/spec/javascripts/teabag/phantomjs/runner_spec.coffee;FI"P/Users/jejacks0n/Projects/teabag/lib/teabag/drivers/phantomjs/runner.coffee;FI"dependency_paths;F[{I" path;FI"Z/Users/jejacks0n/Projects/teabag/spec/javascripts/teabag/phantomjs/runner_spec.coffee;FI" mtime;FI"2013-01-01T20:41:02-07:00;FI" digest;F"%8540c007f81eeb5fd993ac5ce7532db5{I" path;FI"P/Users/jejacks0n/Projects/teabag/lib/teabag/drivers/phantomjs/runner.coffee;FI" mtime;FI"2013-01-16T12:07:54-07:00;FI" digest;F"%67065b2af5d81e4d9a819d266c66ad6aI" _version;F"%ffd318ca8b794f42f5029101c2cf5d91