diff --git a/Guardfile b/Guardfile index 512beef..38c2dc6 100644 --- a/Guardfile +++ b/Guardfile @@ -3,7 +3,6 @@ # watch('file/path') { `command(s)` } # -if false guard 'coffeescript', :input => 'vendor/assets/coffeescripts', :output => 'vendor/assets/javascripts' guard 'shell' do @@ -22,7 +21,6 @@ guard 'rspec', :version => 2, :all_on_start => false do watch(%r{^bin/(.+)}) { |m| "spec/bin/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } end -end guard 'jasmine-headless-webkit', :all_on_start => false do watch(%r{^spec/javascripts/.+_spec\.coffee}) diff --git a/vendor/assets/coffeescripts/intense.coffee b/vendor/assets/coffeescripts/intense.coffee index f24d136..db00e5c 100644 --- a/vendor/assets/coffeescripts/intense.coffee +++ b/vendor/assets/coffeescripts/intense.coffee @@ -20,6 +20,7 @@ window.Intense = { else this useColors: true + moveBack: (count = 1) -> "\033[#{count}D" } for method, code of Intense.methods diff --git a/vendor/assets/coffeescripts/jasmine-extensions.coffee b/vendor/assets/coffeescripts/jasmine-extensions.coffee index 561cf9c..92dd70b 100644 --- a/vendor/assets/coffeescripts/jasmine-extensions.coffee +++ b/vendor/assets/coffeescripts/jasmine-extensions.coffee @@ -73,11 +73,10 @@ if window.JHW pauseAndRun = (onComplete) -> JHW.timerPause() - if this.env.reporter.reportSpecWaiting - this.env.reporter.reportSpecWaiting(this) + jasmine.getEnv().reporter.reportSpecWaiting() + this._execute -> - if this.env.reporter.reportSpecRunning - this.env.reporter.reportSpecRunning(this) + jasmine.getEnv().reporter.reportSpecRunning() JHW.timerDone() onComplete() @@ -92,3 +91,13 @@ if window.JHW result.expectations = jasmine.NestedResults.parseAndStore(arguments.callee.caller.caller.caller.toString()) this.addResult_(result) + + for method in [ "reportSpecWaiting", "reportSpecRunning" ] + generator = (method) -> + (args...) -> + for reporter in @subReporters_ + if reporter[method]? + reporter[method](args...) + + jasmine.MultiReporter.prototype[method] = generator(method) + diff --git a/vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee b/vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee index 069760b..3bdedd0 100644 --- a/vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee +++ b/vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee @@ -6,6 +6,9 @@ class jasmine.HeadlessConsoleReporter @results = [] @failedCount = 0 @length = 0 + @timer = null + @position = 0 + @positions = "|/-\\" reportRunnerResults: (runner) -> return if this.hasError() @@ -67,6 +70,33 @@ class jasmine.HeadlessConsoleReporter spec.finish() spec.suite.finish() + reportSpecWaiting: -> + runner = null + + if !@timer + @timer = true + first = true + + runner = => + @timer = setTimeout( + => + if @timer + JHW.stdout.print(Intense.moveBack()) if !first + JHW.stdout.print(@positions.substr(@position, 1).foreground('yellow')) + @position += 1 + @position %= @positions.length + first = false + runner() + , 750 + ) + runner() + + reportSpecRunning: -> + if @timer + clearTimeout(@timer) + @timer = null + JHW.stdout.print(Intense.moveBack()) + reportSuiteResults: (suite) -> hasError: -> JHW._hasErrors diff --git a/vendor/assets/javascripts/intense.js b/vendor/assets/javascripts/intense.js index 6d885a1..8341721 100644 --- a/vendor/assets/javascripts/intense.js +++ b/vendor/assets/javascripts/intense.js @@ -28,7 +28,11 @@ } } }, - useColors: true + useColors: true, + moveBack: function(count) { + if (count == null) count = 1; + return "\033[" + count + "D"; + } }; _ref = Intense.methods; diff --git a/vendor/assets/javascripts/jasmine-extensions.js b/vendor/assets/javascripts/jasmine-extensions.js index c9b4a93..da5394c 100644 --- a/vendor/assets/javascripts/jasmine-extensions.js +++ b/vendor/assets/javascripts/jasmine-extensions.js @@ -1,5 +1,6 @@ (function() { - var getSplitName, pauseAndRun; + var generator, getSplitName, method, pauseAndRun, _i, _len, _ref; + var __slice = Array.prototype.slice; if (!(typeof jasmine !== "undefined" && jasmine !== null)) { throw new Error("jasmine not laoded!"); @@ -85,7 +86,9 @@ jasmine.WaitsForBlock.prototype._execute = jasmine.WaitsForBlock.prototype.execute; pauseAndRun = function(onComplete) { JHW.timerPause(); + jasmine.getEnv().reporter.reportSpecWaiting(); return this._execute(function() { + jasmine.getEnv().reporter.reportSpecRunning(); JHW.timerDone(); return onComplete(); }); @@ -98,6 +101,28 @@ result.expectations = jasmine.NestedResults.parseAndStore(arguments.callee.caller.caller.caller.toString()); return this.addResult_(result); }; + _ref = ["reportSpecWaiting", "reportSpecRunning"]; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + method = _ref[_i]; + generator = function(method) { + return function() { + var args, reporter, _j, _len2, _ref2, _results; + args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; + _ref2 = this.subReporters_; + _results = []; + for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { + reporter = _ref2[_j]; + if (reporter[method] != null) { + _results.push(reporter[method].apply(reporter, args)); + } else { + _results.push(void 0); + } + } + return _results; + }; + }; + jasmine.MultiReporter.prototype[method] = generator(method); + } } } diff --git a/vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js b/vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js index ea1d365..e96bbb7 100644 --- a/vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js +++ b/vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js @@ -10,6 +10,9 @@ this.results = []; this.failedCount = 0; this.length = 0; + this.timer = null; + this.position = 0; + this.positions = "|/-\\"; } HeadlessConsoleReporter.prototype.reportRunnerResults = function(runner) { @@ -77,6 +80,37 @@ } }; + HeadlessConsoleReporter.prototype.reportSpecWaiting = function() { + var first, runner; + var _this = this; + runner = null; + if (!this.timer) { + this.timer = true; + first = true; + runner = function() { + return _this.timer = setTimeout(function() { + if (_this.timer) { + if (!first) JHW.stdout.print(Intense.moveBack()); + JHW.stdout.print(_this.positions.substr(_this.position, 1).foreground('yellow')); + _this.position += 1; + _this.position %= _this.positions.length; + first = false; + return runner(); + } + }, 750); + }; + return runner(); + } + }; + + HeadlessConsoleReporter.prototype.reportSpecRunning = function() { + if (this.timer) { + clearTimeout(this.timer); + this.timer = null; + return JHW.stdout.print(Intense.moveBack()); + } + }; + HeadlessConsoleReporter.prototype.reportSuiteResults = function(suite) {}; HeadlessConsoleReporter.prototype.hasError = function() {