more cleanup

This commit is contained in:
John Bintz 2012-01-11 14:24:09 -05:00
parent b9b4648a24
commit ed76916205
20 changed files with 14 additions and 470 deletions

11
Gemfile
View File

@ -15,22 +15,17 @@ 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'
gem 'guard-jasmine-headless-webkit', :git => 'git://github.com/johnbintz/guard-jasmine-headless-webkit.git'
gem 'facter'
gem 'mocha'
gem 'cucumber'
gem 'jquery-rails'
gem 'jquery-rails', '~> 1.0.0'
gem 'ejs'
gem 'simplecov'
gem 'guard-jasmine-headless-webkit', :git => 'git://github.com/johnbintz/guard-jasmine-headless-webkit.git'

View File

@ -1,20 +0,0 @@
module Digest
class JasmineTest
def self.file(file)
new
end
def file(file)
self
end
def hexdigest
'test'
end
def update(prefix)
self
end
end
end

View File

@ -1,7 +1,3 @@
require 'jasmine/headless'
require 'jasmine/headless/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
module Digest
autoload :JasmineTest, 'digest/jasmine_test'
end

View File

@ -14,23 +14,9 @@ module Jasmine
desc 'Run Jasmine specs headlessly'
task(name) { run_rake_task }
create_rails_compliant_task if defined?(Rails)
end
private
def create_rails_compliant_task
if Rails.respond_to?(:version) && Rails.version >= "3.1.0"
task 'assets:precompile:for_testing' => :environment do
$stderr.puts "This task is deprecated and will be removed after 2012-01-01"
Rails.application.assets.digest_class = Digest::JasmineTest
Rake::Task['assets:precompile'].invoke
end
end
end
def run_rake_task
case Jasmine::Headless::Runner.run(
:colors => colors,

View File

@ -1,3 +1,4 @@
(function() {
window.HeadlessReporterResult = (function() {
@ -74,3 +75,5 @@
return HeadlessReporterResult;
})();
}).call(this);

View File

@ -1,44 +0,0 @@
(function() {
var code, method, _ref;
window.Intense = {
colors: {
black: 0,
red: 1,
green: 2,
yellow: 3,
blue: 4,
magenta: 5,
cyan: 6,
white: 7
},
methods: {
foreground: function(color) {
if (Intense.useColors) {
return "\033[3" + Intense.colors[color] + "m" + this + "\033[0m";
} else {
return this;
}
},
bright: function() {
if (Intense.useColors) {
return "\033[1m" + this + "\033[0m";
} else {
return this;
}
}
},
useColors: true,
moveBack: function(count) {
if (count == null) count = 1;
return "\033[" + count + "D";
}
};
_ref = Intense.methods;
for (method in _ref) {
code = _ref[method];
String.prototype[method] = code;
}
}).call(this);

View File

@ -1,6 +1,6 @@
(function() {
var generator, getSplitName, method, pauseAndRun, _i, _len, _ref;
var __slice = Array.prototype.slice;
var generator, getSplitName, method, pauseAndRun, _i, _len, _ref,
__slice = Array.prototype.slice;
if (!(typeof jasmine !== "undefined" && jasmine !== null)) {
throw new Error("jasmine not laoded!");

View File

@ -1,26 +0,0 @@
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
jasmine.HeadlessReporter.Console = (function() {
__extends(Console, jasmine.HeadlessReporter.ConsoleBase);
function Console() {
this.displayFailure = __bind(this.displayFailure, this);
this.displaySuccess = __bind(this.displaySuccess, this);
Console.__super__.constructor.apply(this, arguments);
}
Console.prototype.displaySuccess = function(spec) {
return this.print('.'.foreground('green'));
};
Console.prototype.displayFailure = function(spec) {
return this.print('F'.foreground('red'));
};
return Console;
})();
}).call(this);

View File

@ -1,4 +1,4 @@
#= require jasmine.HeadlessReporter.js
#= require jasmine.HeadlessReporter
class jasmine.HeadlessReporter.ConsoleBase extends jasmine.HeadlessReporter
constructor: (@callback = null) ->

View File

@ -1,118 +0,0 @@
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
jasmine.HeadlessReporter.ConsoleBase = (function() {
__extends(ConsoleBase, jasmine.HeadlessReporter);
function ConsoleBase(callback) {
this.callback = callback != null ? callback : null;
this._waitRunner = __bind(this._waitRunner, this);
ConsoleBase.__super__.constructor.call(this, this.callback);
this.position = 0;
this.positions = "|/-\\";
}
ConsoleBase.prototype.formatResultLine = function(runtime) {
var line;
line = [];
line.push(this.length);
line.push((this.length === 1 ? "test" : "tests") + ',');
line.push(this.failedCount);
line.push((this.failedCount === 1 ? "failure" : "failures") + ',');
line.push(runtime);
line.push((runtime === 1.0 ? "sec" : "secs") + '.');
return line.join(' ');
};
ConsoleBase.prototype.reportRunnerResults = function(runner) {
var result, resultLine, _i, _len, _ref;
ConsoleBase.__super__.reportRunnerResults.call(this);
this.print("\n");
resultLine = this.formatResultLine(this._runtime());
if (this.failedCount === 0) {
this.puts(("PASS: " + resultLine).foreground('green'));
} else {
this.puts(("FAIL: " + resultLine).foreground('red'));
}
_ref = this.results;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
result = _ref[_i];
this.puts(result.toString());
}
return this.puts("\nTest ordering seed: --seed " + (JHW.getSeed()));
};
ConsoleBase.prototype.reportRunnerStarting = function(runner) {
ConsoleBase.__super__.reportRunnerStarting.call(this, runner);
if (!this.hasError()) {
return this.puts("\nRunning Jasmine specs...".bright());
}
};
ConsoleBase.prototype.reportSpecWaiting = function() {
if (!this.timer) {
this.timer = true;
this.first = true;
return this._waitRunner();
}
};
ConsoleBase.prototype.reportSpecRunning = function() {
if (this.timer) {
clearTimeout(this.timer);
this.timer = null;
return this.print(Intense.moveBack());
}
};
ConsoleBase.prototype.reportSpecResults = function(spec) {
var _this = this;
ConsoleBase.__super__.reportSpecResults.call(this, spec);
return this._reportSpecResult(spec, {
success: function(results) {
return _this.displaySuccess(spec);
},
failure: function(results) {
_this.displayFailure(spec);
return _this.reportFailureResult(results, new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName()));
}
});
};
ConsoleBase.prototype.reportFailureResult = function(results, failureResult) {
var foundLine, result, testCount, _i, _len, _ref;
testCount = 1;
_ref = results.getItems();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
result = _ref[_i];
if (result.type === 'expect' && !result.passed_) {
if (foundLine = result.expectations[testCount - 1]) {
result.line = foundLine[0], result.lineNumber = foundLine[1];
}
failureResult.addResult(result);
}
testCount += 1;
}
return this.results.push(failureResult);
};
ConsoleBase.prototype._waitRunner = function() {
var _this = this;
return this.timer = setTimeout(function() {
if (_this.timer) {
if (!_this.first) _this.print(Intense.moveBack());
_this.print(_this.positions.substr(_this.position, 1).foreground('yellow'));
_this.position += 1;
_this.position %= _this.positions.length;
_this.first = false;
return _this._waitRunner();
}
}, 750);
};
return ConsoleBase;
})();
}).call(this);

View File

@ -1,4 +1,4 @@
#= require jasmine.HeadlessReporter.js
#= require jasmine.HeadlessReporter
#
class jasmine.HeadlessReporter.File extends jasmine.HeadlessReporter
reportRunnerResults: (runner) ->

View File

@ -1,41 +0,0 @@
(function() {
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
jasmine.HeadlessReporter.File = (function() {
__extends(File, jasmine.HeadlessReporter);
function File() {
File.__super__.constructor.apply(this, arguments);
}
File.prototype.reportRunnerResults = function(runner) {
var output;
File.__super__.reportRunnerResults.call(this, runner);
output = "TOTAL||" + this.length + "||" + this.failedCount + "||" + (this._runtime()) + "||" + (JHW._hasErrors ? "T" : "F");
this.puts(output);
return this.puts("SEED||" + (JHW.getSeed()));
};
File.prototype.consoleLogUsed = function(msg) {
return this.puts("CONSOLE||" + msg);
};
File.prototype.reportSpecResults = function(spec) {
var _this = this;
File.__super__.reportSpecResults.call(this, spec);
return this._reportSpecResult(spec, {
success: function(results) {
return _this.puts("PASS||" + spec.getJHWSpecInformation());
},
failure: function(results) {
return _this.puts("FAIL||" + spec.getJHWSpecInformation());
}
});
};
return File;
})();
}).call(this);

View File

@ -1,4 +1,4 @@
#= require jasmine.HeadlessReporter.js
#= require jasmine.HeadlessReporter
class jasmine.HeadlessReporter.Tap extends jasmine.HeadlessReporter
constructor: (@outputTarget = null) ->

View File

@ -1,40 +0,0 @@
(function() {
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
jasmine.HeadlessReporter.Tap = (function() {
__extends(Tap, jasmine.HeadlessReporter);
function Tap(outputTarget) {
this.outputTarget = outputTarget != null ? outputTarget : null;
Tap.__super__.constructor.call(this, this.outputTarget);
this.output = [];
}
Tap.prototype.reportRunnerResults = function(runner) {
Tap.__super__.reportRunnerResults.call(this, runner);
if (this.output.length > 0) this.output.unshift("1.." + this.output.length);
return this.puts(this.output.join("\n"));
};
Tap.prototype.reportSpecResults = function(spec) {
var description, index;
var _this = this;
Tap.__super__.reportSpecResults.call(this, spec);
index = this.output.length + 1;
description = spec.getSpecSplitName().join(' ');
return this._reportSpecResult(spec, {
success: function(results) {
return _this.output.push("ok " + index + " " + description);
},
failure: function(results) {
return _this.output.push("not ok " + index + " " + description);
}
});
};
return Tap;
})();
}).call(this);

View File

@ -11,7 +11,9 @@ class jasmine.HeadlessReporter.Verbose extends jasmine.HeadlessReporter.ConsoleB
currentLastNames = (@lastNames || []).slice(0)
@lastNames = spec.getSpecSplitName()
this.puts(this.indentSpec(@lastNames, currentLastNames, color).join("\n"))
for line in this.indentSpec(@lastNames, currentLastNames, color)
if line? and !_.isEmpty(line)
this.puts(line)
indentSpec: (current, last, color) =>
last = last.slice(0)

View File

@ -1,72 +0,0 @@
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
jasmine.HeadlessReporter.Verbose = (function() {
__extends(Verbose, jasmine.HeadlessReporter.ConsoleBase);
function Verbose() {
this.colorLine = __bind(this.colorLine, this);
this.indentLines = __bind(this.indentLines, this);
this.indentSpec = __bind(this.indentSpec, this);
this.displaySpec = __bind(this.displaySpec, this);
this.displayFailure = __bind(this.displayFailure, this);
this.displaySuccess = __bind(this.displaySuccess, this);
Verbose.__super__.constructor.apply(this, arguments);
}
Verbose.prototype.displaySuccess = function(spec) {
return this.displaySpec(spec, 'green');
};
Verbose.prototype.displayFailure = function(spec) {
return this.displaySpec(spec, 'red');
};
Verbose.prototype.displaySpec = function(spec, color) {
var currentLastNames;
currentLastNames = (this.lastNames || []).slice(0);
this.lastNames = spec.getSpecSplitName();
return this.puts(this.indentSpec(this.lastNames, currentLastNames, color).join("\n"));
};
Verbose.prototype.indentSpec = function(current, last, color) {
var lines, name, _i, _len;
last = last.slice(0);
lines = [];
for (_i = 0, _len = current.length; _i < _len; _i++) {
name = current[_i];
if (last.shift() !== name) {
lines.push(name);
} else {
lines.push(null);
}
}
return this.indentLines(lines, color);
};
Verbose.prototype.indentLines = function(lines, color) {
var indent, line, output, outputLine, _i, _len;
indent = '';
output = [];
for (_i = 0, _len = lines.length; _i < _len; _i++) {
line = lines[_i];
if (line != null) {
outputLine = indent;
outputLine += this.colorLine(line, color);
output.push(outputLine);
}
indent += ' ';
}
return output;
};
Verbose.prototype.colorLine = function(line, color) {
return line.foreground(color);
};
return Verbose;
})();
}).call(this);

View File

@ -1,77 +0,0 @@
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
if (!(typeof jasmine !== "undefined" && jasmine !== null)) {
throw new Error("jasmine not loaded!");
}
jasmine.HeadlessReporter = (function() {
function HeadlessReporter(outputTarget) {
this.outputTarget = outputTarget != null ? outputTarget : null;
this.puts = __bind(this.puts, this);
this.print = __bind(this.print, this);
this.results = [];
this.failedCount = 0;
this.length = 0;
this.timer = null;
}
HeadlessReporter.prototype.hasError = function() {
return JHW._hasErrors;
};
HeadlessReporter.prototype.reportSpecStarting = function(spec) {
if (this.hasError()) {
spec.finish();
return spec.suite.finish();
}
};
HeadlessReporter.prototype.reportSuiteResults = function(suite) {};
HeadlessReporter.prototype.reportRunnerStarting = function(runner) {
return this.startTime = new Date();
};
HeadlessReporter.prototype.reportRunnerResults = function(runner) {
if (this.hasError()) return;
if (this.failedCount !== 0) JHW.hasSpecFailure();
JHW.finishSuite();
if (window.JHW) return window.onbeforeunload = null;
};
HeadlessReporter.prototype.reportSpecResults = function(spec) {
if (this.hasError()) return;
return JHW.ping();
};
HeadlessReporter.prototype._reportSpecResult = function(spec, options) {
var results;
results = spec.results();
this.length++;
if (results.passed()) {
return options.success(results, spec);
} else {
this.failedCount++;
return options.failure(results, spec);
}
};
HeadlessReporter.prototype._runtime = function() {
return (new Date() - this.startTime) / 1000.0;
};
HeadlessReporter.prototype.print = function(output) {
return JHW.print(this.outputTarget, output);
};
HeadlessReporter.prototype.puts = function(output) {
return JHW.print(this.outputTarget, output + "\n");
};
return HeadlessReporter;
})();
}).call(this);