diff --git a/CHANGELOG.md b/CHANGELOG.md index e733ad5..9f4b29e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,3 @@ -## 0.6.1 - -* Ensure YAML is loaded before use -* Make sure specs can't break out of the page they're running in - ## 0.6.0 * File and line number information for failing specs diff --git a/ext/jasmine-webkit-specrunner/specrunner.cpp b/ext/jasmine-webkit-specrunner/specrunner.cpp index d6b0c3c..1a52982 100644 --- a/ext/jasmine-webkit-specrunner/specrunner.cpp +++ b/ext/jasmine-webkit-specrunner/specrunner.cpp @@ -35,9 +35,6 @@ class HeadlessSpecRunnerPage: public QWebPage { Q_OBJECT -public: - HeadlessSpecRunnerPage(); - void oneFalseConfirm(); signals: void consoleLog(const QString &msg, int lineNumber, const QString &sourceID); void internalLog(const QString ¬e, const QString &msg); @@ -45,17 +42,8 @@ protected: void javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID); bool javaScriptConfirm(QWebFrame *frame, const QString &msg); void javaScriptAlert(QWebFrame *frame, const QString &msg); -private: - bool confirmResult; }; -HeadlessSpecRunnerPage::HeadlessSpecRunnerPage() - : QWebPage() - , confirmResult(true) -{ - -} - void HeadlessSpecRunnerPage::javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID) { emit consoleLog(message, lineNumber, sourceID); @@ -63,13 +51,8 @@ void HeadlessSpecRunnerPage::javaScriptConsoleMessage(const QString &message, in bool HeadlessSpecRunnerPage::javaScriptConfirm(QWebFrame *frame, const QString &msg) { - if (confirmResult) { - emit internalLog("TODO", "jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm for now. Returning true."); - return true; - } else { - confirmResult = true; - return false; - } + emit internalLog("TODO", "jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm for now. Returning true."); + return true; } void HeadlessSpecRunnerPage::javaScriptAlert(QWebFrame *frame, const QString &msg) @@ -77,11 +60,6 @@ void HeadlessSpecRunnerPage::javaScriptAlert(QWebFrame *frame, const QString &ms emit internalLog("alert", msg); } -void HeadlessSpecRunnerPage::oneFalseConfirm() -{ - confirmResult = false; -} - class HeadlessSpecRunner: public QObject { Q_OBJECT @@ -93,7 +71,6 @@ public: void go(); public slots: void log(const QString &msg); - void leavePageAttempt(const QString &msg); void specPassed(); void specFailed(const QString &specDetail); void printName(const QString &name); @@ -273,16 +250,6 @@ void HeadlessSpecRunner::log(const QString &msg) std::cout << std::endl; } -void HeadlessSpecRunner::leavePageAttempt(const QString &msg) -{ - red(); - std::cout << "[error] "; - clear(); - std::cout << qPrintable(msg) << std::endl; - m_page.oneFalseConfirm(); - hasErrors = true; -} - void HeadlessSpecRunner::printName(const QString &name) { std::cout << std::endl << std::endl; diff --git a/jasmine/jasmine.headless-reporter.coffee b/jasmine/jasmine.headless-reporter.coffee index 45ec549..447c102 100644 --- a/jasmine/jasmine.headless-reporter.coffee +++ b/jasmine/jasmine.headless-reporter.coffee @@ -13,7 +13,8 @@ class window.HeadlessReporterResult JHW.printName(output) for result in @results - JHW.printResult(result) + do (result) => + JHW.printResult(result) _findSpecLine: -> bestChoice = { accuracy: 0, file: null, lineNumber: null } @@ -49,15 +50,15 @@ jasmine.Spec.prototype.getSpecSplitName = -> parts class jasmine.HeadlessReporter - constructor: (@callback = null) -> + constructor: -> @results = [] @failedCount = 0 @length = 0 reportRunnerResults: (runner) -> for result in @results - result.print() + do (result) => + result.print() - this.callback() if @callback JHW.finishSuite((new Date() - @startTime) / 1000.0, @length, @failedCount) reportRunnerStarting: (runner) -> @startTime = new Date() @@ -71,8 +72,9 @@ class jasmine.HeadlessReporter @failedCount++ failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName()) for result in results.getItems() - if result.type == 'expect' and !result.passed_ - failureResult.addResult(result.message) + do (result) => + if result.type == 'expect' and !result.passed_ + failureResult.addResult(result.message) @results.push(failureResult) reportSpecStarting: (spec) -> reportSuiteResults: (suite) -> diff --git a/jasmine/jasmine.headless-reporter.js b/jasmine/jasmine.headless-reporter.js index b95b23c..d9b4eb5 100644 --- a/jasmine/jasmine.headless-reporter.js +++ b/jasmine/jasmine.headless-reporter.js @@ -1,4 +1,5 @@ (function() { + var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; if (!(typeof jasmine !== "undefined" && jasmine !== null)) { throw new Error("jasmine not laoded!"); } @@ -23,7 +24,9 @@ _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { result = _ref[_i]; - _results.push(JHW.printResult(result)); + _results.push(__bind(function(result) { + return JHW.printResult(result); + }, this)(result)); } return _results; }; @@ -80,21 +83,20 @@ return parts; }; jasmine.HeadlessReporter = (function() { - function HeadlessReporter(callback) { - this.callback = callback != null ? callback : null; + function HeadlessReporter() { this.results = []; this.failedCount = 0; this.length = 0; } HeadlessReporter.prototype.reportRunnerResults = function(runner) { - var result, _i, _len, _ref; + var result, _fn, _i, _len, _ref; _ref = this.results; + _fn = __bind(function(result) { + return result.print(); + }, this); for (_i = 0, _len = _ref.length; _i < _len; _i++) { result = _ref[_i]; - result.print(); - } - if (this.callback) { - this.callback(); + _fn(result); } return JHW.finishSuite((new Date() - this.startTime) / 1000.0, this.length, this.failedCount); }; @@ -102,7 +104,7 @@ return this.startTime = new Date(); }; HeadlessReporter.prototype.reportSpecResults = function(spec) { - var failureResult, result, results, _i, _len, _ref; + var failureResult, result, results, _fn, _i, _len, _ref; results = spec.results(); this.length++; if (results.passed()) { @@ -112,11 +114,14 @@ this.failedCount++; failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName()); _ref = results.getItems(); + _fn = __bind(function(result) { + if (result.type === 'expect' && !result.passed_) { + return failureResult.addResult(result.message); + } + }, this); for (_i = 0, _len = _ref.length; _i < _len; _i++) { result = _ref[_i]; - if (result.type === 'expect' && !result.passed_) { - failureResult.addResult(result.message); - } + _fn(result); } return this.results.push(failureResult); } diff --git a/lib/jasmine-headless-webkit/version.rb b/lib/jasmine-headless-webkit/version.rb index 8c0e0e8..eba381d 100644 --- a/lib/jasmine-headless-webkit/version.rb +++ b/lib/jasmine-headless-webkit/version.rb @@ -1,7 +1,7 @@ module Jasmine module Headless module Webkit - VERSION = "0.6.1" + VERSION = "0.6.0" end end end diff --git a/lib/jasmine/headless/runner.rb b/lib/jasmine/headless/runner.rb index e4757d7..4be91c9 100644 --- a/lib/jasmine/headless/runner.rb +++ b/lib/jasmine/headless/runner.rb @@ -9,8 +9,6 @@ require 'rainbow' require 'jasmine/files_list' require 'jasmine/template_writer' -require 'yaml' - module Jasmine module Headless class Runner diff --git a/lib/jasmine/template_writer.rb b/lib/jasmine/template_writer.rb index 762dd7e..6a99ca4 100644 --- a/lib/jasmine/template_writer.rb +++ b/lib/jasmine/template_writer.rb @@ -31,16 +31,6 @@ module Jasmine }, pp: function(data) { JHW.log(jasmine ? jasmine.pp(data) : JSON.stringify(data)); } }; - - window.onbeforeunload = function(e) { - JHW.leavePageAttempt('The code tried to leave the test page. Check for unhandled form submits and link clicks.'); - - if (e = e || window.event) { - e.returnValue = "leaving"; - } - - return "leaving"; - }; #{files.join("\n")} diff --git a/lib/qt/qmake.rb b/lib/qt/qmake.rb index e1ce112..9755652 100644 --- a/lib/qt/qmake.rb +++ b/lib/qt/qmake.rb @@ -17,6 +17,8 @@ module Qt case platform when :linux "#{path} -spec linux-g++" + when :freebsd + "#{path} -spec freebsd-g++" when :mac_os_x "#{path} -spec macx-g++" end @@ -37,17 +39,19 @@ module Qt # We need integration tests for these! # def path - get_exe_path('qmake') + get_exe_path('qmake-qt4') || get_exe_path('qmake') end def make_path - get_exe_path('make') + get_exe_path('gmake') || get_exe_path('make') end def platform case RbConfig::CONFIG['host_os'] when /linux/ :linux + when /freebsd/i + :freebsd when /darwin/ :mac_os_x end @@ -77,6 +81,8 @@ module Qt case platform when :linux %{sudo apt-get install make or sudo yum install make} + when :freebsd + %{install /usr/ports/devel/gmake} when :darwin %{Install XCode, and/or sudo port install make} end @@ -98,6 +104,10 @@ MSG <<-MSG sudo apt-get install libqt4-dev qt4-qmake on Debian-based systems, or downloading Nokia's prebuilt binary at http://qt.nokia.com/downloads/ +MSG + when :freebsd + <<-MSG +Install /usr/ports/devel/qmake4. MSG when :darwin <<-MSG @@ -122,6 +132,10 @@ MSG <<-MSG sudo apt-get install libqt4-dev qt4-qmake on Debian-based systems, or downloading Nokia's prebuilt binary at http://qt.nokia.com/downloads/ +MSG + when :freebsd + <<-MSG +Install /usr/ports/www/qt4-webkit. MSG when :darwin <<-MSG diff --git a/spec/bin/jasmine-headless-webkit_spec.rb b/spec/bin/jasmine-headless-webkit_spec.rb index ebe627d..cee4707 100644 --- a/spec/bin/jasmine-headless-webkit_spec.rb +++ b/spec/bin/jasmine-headless-webkit_spec.rb @@ -60,24 +60,6 @@ describe "jasmine-headless-webkit" do end end - describe 'tries to leave page' do - it "should not leave the page nor loop" do - system %{bin/jasmine-headless-webkit -j spec/jasmine/leave_page/leave_page.yml --report #{report}} - $?.exitstatus.should == 1 - - report.should be_a_report_containing(2, 0, false) - end - end - - describe 'tries to click a button' do - it "should not leave the page nor loop" do - system %{bin/jasmine-headless-webkit -j spec/jasmine/click_button/click_button.yml --report #{report}} - $?.exitstatus.should == 0 - - report.should be_a_report_containing(0, 0, false) - end - end - describe 'with filtered run' do context "don't run a full run, just the filtered run" do it "should succeed and run both" do diff --git a/spec/jasmine/click_button/click_button.js b/spec/jasmine/click_button/click_button.js deleted file mode 100644 index 628dae2..0000000 --- a/spec/jasmine/click_button/click_button.js +++ /dev/null @@ -1,5 +0,0 @@ -function yes() { - $('body').append('