diff --git a/Gemfile b/Gemfile index 4761cc8..45b425a 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,15 @@ gem 'guard-shell' gem 'guard-coffeescript' gem 'guard-cucumber' +require 'rbconfig' +case RbConfig::CONFIG['host_os'] +when /darwin/ + gem 'growl' + gem 'rb-fsevent' +when /linux/ + gem 'libnotify' +end + gem 'growl' gem 'rake', '0.8.7' gem 'mocha', '0.9.12' diff --git a/ext/jasmine-webkit-specrunner/Page.cpp b/ext/jasmine-webkit-specrunner/Page.cpp index b3f6c3d..cdfa396 100644 --- a/ext/jasmine-webkit-specrunner/Page.cpp +++ b/ext/jasmine-webkit-specrunner/Page.cpp @@ -11,6 +11,5 @@ void Page::javaScriptConsoleMessage(const QString & message, int lineNumber, con } void Page::javaScriptAlert(QWebFrame *, const QString &) {} -bool Page::javaScriptConfirm(QWebFrame *, const QString &) { - return false; -} +bool Page::javaScriptConfirm(QWebFrame *, const QString &) { return false; } +bool Page::javaScriptPrompt(QWebFrame *, const QString &, const QString &, QString *) { return false; } diff --git a/ext/jasmine-webkit-specrunner/Page.h b/ext/jasmine-webkit-specrunner/Page.h index 74c6f77..bae094d 100644 --- a/ext/jasmine-webkit-specrunner/Page.h +++ b/ext/jasmine-webkit-specrunner/Page.h @@ -12,6 +12,7 @@ class Page: public QWebPage { void javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID); void javaScriptAlert(QWebFrame *, const QString &); bool javaScriptConfirm(QWebFrame *, const QString &); + bool javaScriptPrompt(QWebFrame *, const QString &, const QString &, QString *); signals: void handleError(const QString & message, int lineNumber, const QString & sourceID); }; diff --git a/features/bin/with_window_prompt.feature b/features/bin/with_window_prompt.feature new file mode 100644 index 0000000..0f1dac1 --- /dev/null +++ b/features/bin/with_window_prompt.feature @@ -0,0 +1,7 @@ +Feature: Bin - With window.prompt() + Scenario: Alert the user that window.prompt() needs to be stubbed + Given I have a test suite + When I run `bin/jasmine-headless-webkit -j spec/jasmine/window_prompt/window_prompt.yml` + Then the exit status should be 0 + And the output should include "You should mock window.prompt" + diff --git a/spec/jasmine/window_prompt/source.js b/spec/jasmine/window_prompt/source.js new file mode 100644 index 0000000..220eb03 --- /dev/null +++ b/spec/jasmine/window_prompt/source.js @@ -0,0 +1,2 @@ +window.prompt("Yes! Hi!"); + diff --git a/spec/jasmine/window_prompt/window_prompt.yml b/spec/jasmine/window_prompt/window_prompt.yml new file mode 100644 index 0000000..13b11ef --- /dev/null +++ b/spec/jasmine/window_prompt/window_prompt.yml @@ -0,0 +1,4 @@ +src_dir: spec/jasmine/window_prompt +src_files: +- '**/*.js' + diff --git a/vendor/assets/coffeescripts/prolog.coffee b/vendor/assets/coffeescripts/prolog.coffee index da892df..3ca660e 100644 --- a/vendor/assets/coffeescripts/prolog.coffee +++ b/vendor/assets/coffeescripts/prolog.coffee @@ -48,8 +48,13 @@ if window.JHW false # dialogs - window.confirm = (message) -> - puts "#{"[confirm]".foreground('red')} jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm. Returning true." + window.confirm = -> + puts "#{"[confirm]".foreground('red')} You should mock window.confirm. Returning true." + + true + + window.prompt = -> + puts "#{"[prompt]".foreground('red')} You should mock window.prompt. Returning true." true diff --git a/vendor/assets/javascripts/prolog.js b/vendor/assets/javascripts/prolog.js index 5405669..72a490f 100644 --- a/vendor/assets/javascripts/prolog.js +++ b/vendor/assets/javascripts/prolog.js @@ -1,6 +1,5 @@ (function() { var puts; - if (window.JHW) { window.console = { log: function(data) { @@ -44,7 +43,9 @@ e = e || window.event; JHW.hasError(); puts("The code tried to leave the test page. Check for unhandled form submits and link clicks."); - if (e) e.returnValue = 'string'; + if (e) { + e.returnValue = 'string'; + } return 'string'; }; JHW._hasErrors = false; @@ -53,8 +54,12 @@ JHW._hasErrors = true; return false; }; - window.confirm = function(message) { - puts("" + ("[confirm]".foreground('red')) + " jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm. Returning true."); + window.confirm = function() { + puts("" + ("[confirm]".foreground('red')) + " You should mock window.confirm. Returning true."); + return true; + }; + window.prompt = function() { + puts("" + ("[prompt]".foreground('red')) + " You should mock window.prompt. Returning true."); return true; }; window.alert = function(message) { @@ -70,15 +75,14 @@ _ref = jasmine.getEnv().reporter.subReporters_; for (_i = 0, _len = _ref.length; _i < _len; _i++) { reporter = _ref[_i]; - if (reporter.consoleLogUsed != null) reporter.consoleLogUsed(msg); + if (reporter.consoleLogUsed != null) { + reporter.consoleLogUsed(msg); + } } JHW._usedConsole = true; return puts(msg); }; } - window.CoffeeScriptToFilename = {}; - window.CSTF = window.CoffeeScriptToFilename; - }).call(this);