more furniture rearranging
This commit is contained in:
parent
befd0b4a2d
commit
7b91fc5a76
@ -27,7 +27,7 @@ module Jasmine
|
||||
File.join(Jasmine::Core.path, "jasmine.js"),
|
||||
File.join(Jasmine::Core.path, "jasmine-html.js"),
|
||||
File.join(Jasmine::Core.path, "jasmine.css")
|
||||
] + %w{jasmine-extensions intense headless_reporter_result jasmine.headless-reporter jsDump beautify-html}.collect { |name|
|
||||
] + %w{jasmine-extensions intense headless_reporter_result jasmine.HeadlessConsoleReporter jsDump beautify-html}.collect { |name|
|
||||
Jasmine::Headless.root.join("vendor/assets/javascripts/#{name}.js").to_s
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
|
||||
<title>Jasmine Test Runner - Generated by jasmine-headless-webkit</title>
|
||||
<script type="text/javascript" src="<%= Jasmine::Headless.root.join('vendor/assets/javascripts/prolog.js') %>"</script>
|
||||
<script type="text/javascript" src="<%= Jasmine::Headless.root.join('vendor/assets/javascripts/prolog.js') %>"></script>
|
||||
<%= files.join("\n") %>
|
||||
<script type="text/javascript">
|
||||
if (window.JHW) { HeadlessReporterResult.specLineNumbers = <%= MultiJson.encode(spec_lines) %>; }
|
||||
@ -11,18 +11,21 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
jasmine.getEnv().console = {
|
||||
log: function(msg) { JHW.stdout.puts(msg) }
|
||||
}
|
||||
|
||||
window._onload = window.onload
|
||||
|
||||
window.onload = function() {
|
||||
if (window._onload) { window._onload() }
|
||||
|
||||
if (window.JHW) {
|
||||
jasmine.getEnv().addReporter(new jasmine.HeadlessReporter(function() {
|
||||
window.onbeforeunload = null;
|
||||
}));
|
||||
jasmine.getEnv().addReporter(new jasmine.HeadlessConsoleReporter());
|
||||
} else {
|
||||
jasmine.getEnv().addReporter(new jasmine.HtmlReporter());
|
||||
}
|
||||
|
||||
|
||||
jasmine.getEnv().execute();
|
||||
}
|
||||
</script>
|
||||
|
@ -12,11 +12,11 @@ describe 'HeadlessReporterResult', ->
|
||||
expect(HeadlessReporterResult.findSpecLine([ 'name', 'of', 'test' ]).lineNumber).toEqual(3)
|
||||
expect(HeadlessReporterResult.findSpecLine([ 'other', 'of', 'test' ]).lineNumber).toEqual(10)
|
||||
|
||||
describe 'jasmine.HeadlessReporter', ->
|
||||
describe 'jasmine.HeadlessConsoleReporter', ->
|
||||
reporter = null
|
||||
|
||||
beforeEach ->
|
||||
reporter = new jasmine.HeadlessReporter()
|
||||
reporter = new jasmine.HeadlessConsoleReporter()
|
||||
|
||||
it 'should stop running specs if there are errors reported', ->
|
||||
# otherwise it gets really confusing!
|
@ -17,7 +17,7 @@ describe Jasmine::FilesList do
|
||||
File.expand_path('vendor/assets/javascripts/jasmine-extensions.js'),
|
||||
File.expand_path('vendor/assets/javascripts/intense.js'),
|
||||
File.expand_path('vendor/assets/javascripts/headless_reporter_result.js'),
|
||||
File.expand_path('vendor/assets/javascripts/jasmine.headless-reporter.js'),
|
||||
File.expand_path('vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js'),
|
||||
File.expand_path('vendor/assets/javascripts/jsDump.js'),
|
||||
File.expand_path('vendor/assets/javascripts/beautify-html.js'),
|
||||
]
|
||||
|
85
vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee
vendored
Normal file
85
vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
if !jasmine?
|
||||
throw new Error("jasmine not loaded!")
|
||||
|
||||
class jasmine.HeadlessConsoleReporter
|
||||
constructor: (@callback = null) ->
|
||||
@results = []
|
||||
@failedCount = 0
|
||||
@length = 0
|
||||
|
||||
reportRunnerResults: (runner) ->
|
||||
return if this.hasError()
|
||||
|
||||
if window.JHW
|
||||
window.onbeforeunload = null
|
||||
|
||||
runtime = (new Date() - @startTime) / 1000.0
|
||||
|
||||
JHW.stdout.print("\n")
|
||||
|
||||
resultLine = this._formatResultLine(runtime)
|
||||
|
||||
if @failedCount == 0
|
||||
JHW.stdout.puts("PASS: #{resultLine}".foreground('green'))
|
||||
else
|
||||
JHW.stdout.puts("FAIL: #{resultLine}".foreground('red'))
|
||||
|
||||
output = "TOTAL||#{@length}||#{@failedCount}||#{runtime}||#{if JHW._hasErrors then "T" else "F"}"
|
||||
|
||||
JHW.report.puts(output)
|
||||
result.print() for result in @results
|
||||
|
||||
JHW.finishSuite()
|
||||
|
||||
reportRunnerStarting: (runner) ->
|
||||
@startTime = new Date()
|
||||
JHW.stdout.puts("\nRunning Jasmine specs...".bright())
|
||||
|
||||
reportSpecResults: (spec) ->
|
||||
return if this.hasError()
|
||||
|
||||
results = spec.results()
|
||||
|
||||
@length++
|
||||
if results.passed()
|
||||
JHW.stdout.print('.'.foreground('green'))
|
||||
JHW.report.puts("PASS||" + spec.getJHWSpecInformation())
|
||||
else
|
||||
JHW.stdout.print('F'.foreground('red'))
|
||||
JHW.report.puts("FAIL||" + spec.getJHWSpecInformation())
|
||||
JHW.hasError()
|
||||
|
||||
@failedCount++
|
||||
failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName())
|
||||
testCount = 1
|
||||
|
||||
for result in results.getItems()
|
||||
if result.type == 'expect' and !result.passed_
|
||||
if foundLine = result.expectations[testCount - 1]
|
||||
[ result.line, result.lineNumber ] = foundLine
|
||||
failureResult.addResult(result)
|
||||
testCount += 1
|
||||
@results.push(failureResult)
|
||||
|
||||
reportSpecStarting: (spec) ->
|
||||
if this.hasError()
|
||||
spec.finish()
|
||||
spec.suite.finish()
|
||||
|
||||
reportSuiteResults: (suite) ->
|
||||
hasError: ->
|
||||
JHW._hasErrors
|
||||
|
||||
_formatResultLine: (runtime) ->
|
||||
line = []
|
||||
line.push(@length)
|
||||
line.push((if @length == 1 then "test" else "tests") + ',')
|
||||
|
||||
line.push(@failedCount)
|
||||
line.push((if @failedCount == 1 then "failure" else "failures") + ',')
|
||||
|
||||
line.push(runtime)
|
||||
line.push((if runtime == 1.0 then "sec" else "secs") + '.')
|
||||
|
||||
line.join(' ')
|
||||
|
@ -3,83 +3,3 @@ if !jasmine?
|
||||
|
||||
# The reporter itself.
|
||||
class jasmine.HeadlessReporter
|
||||
constructor: (@callback = null) ->
|
||||
@results = []
|
||||
@failedCount = 0
|
||||
@length = 0
|
||||
|
||||
reportRunnerResults: (runner) ->
|
||||
return if this.hasError()
|
||||
|
||||
this.callback() if @callback
|
||||
|
||||
runtime = (new Date() - @startTime) / 1000.0
|
||||
|
||||
JHW.stdout.print("\n")
|
||||
|
||||
resultLine = this._formatResultLine(runtime)
|
||||
|
||||
if @failedCount == 0
|
||||
JHW.stdout.puts("PASS: #{resultLine}".foreground('green'))
|
||||
else
|
||||
JHW.stdout.puts("FAIL: #{resultLine}".foreground('red'))
|
||||
|
||||
output = "TOTAL||#{@length}||#{@failedCount}||#{runtime}||#{if JHW._hasErrors then "T" else "F"}"
|
||||
|
||||
JHW.report.puts(output)
|
||||
result.print() for result in @results
|
||||
|
||||
JHW.finishSuite()
|
||||
|
||||
reportRunnerStarting: (runner) ->
|
||||
@startTime = new Date()
|
||||
JHW.stdout.puts("\nRunning Jasmine specs...".bright())
|
||||
|
||||
reportSpecResults: (spec) ->
|
||||
return if this.hasError()
|
||||
|
||||
results = spec.results()
|
||||
|
||||
@length++
|
||||
if results.passed()
|
||||
JHW.stdout.print('.'.foreground('green'))
|
||||
JHW.report.puts("PASS||" + spec.getJHWSpecInformation())
|
||||
else
|
||||
JHW.stdout.print('F'.foreground('red'))
|
||||
JHW.report.puts("FAIL||" + spec.getJHWSpecInformation())
|
||||
JHW.hasError()
|
||||
|
||||
@failedCount++
|
||||
failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName())
|
||||
testCount = 1
|
||||
|
||||
for result in results.getItems()
|
||||
if result.type == 'expect' and !result.passed_
|
||||
if foundLine = result.expectations[testCount - 1]
|
||||
[ result.line, result.lineNumber ] = foundLine
|
||||
failureResult.addResult(result)
|
||||
testCount += 1
|
||||
@results.push(failureResult)
|
||||
|
||||
reportSpecStarting: (spec) ->
|
||||
if this.hasError()
|
||||
spec.finish()
|
||||
spec.suite.finish()
|
||||
|
||||
reportSuiteResults: (suite) ->
|
||||
hasError: ->
|
||||
JHW._hasErrors
|
||||
|
||||
_formatResultLine: (runtime) ->
|
||||
line = []
|
||||
line.push(@length)
|
||||
line.push((if @length == 1 then "test" else "tests") + ',')
|
||||
|
||||
line.push(@failedCount)
|
||||
line.push((if @failedCount == 1 then "failure" else "failures") + ',')
|
||||
|
||||
line.push(runtime)
|
||||
line.push((if runtime == 1.0 then "sec" else "secs") + '.')
|
||||
|
||||
line.join(' ')
|
||||
|
||||
|
3
vendor/assets/coffeescripts/prolog.coffee
vendored
3
vendor/assets/coffeescripts/prolog.coffee
vendored
@ -18,8 +18,10 @@ if window.JHW
|
||||
JHW.log(dump)
|
||||
else
|
||||
JHW.log("jsDump: #{dump}")
|
||||
|
||||
pp: (data) ->
|
||||
JHW.log(if jasmine then jasmine.pp(data) else console.log(data))
|
||||
|
||||
peek: (data) ->
|
||||
console.log(data)
|
||||
data
|
||||
@ -37,7 +39,6 @@ if window.JHW
|
||||
JHW.stderr.puts("[alert] ".foreground('red') + message)
|
||||
|
||||
JHW._hasErrors = false
|
||||
|
||||
JHW._handleError = (message, lineNumber, sourceURL) ->
|
||||
JHW.stderr.puts(message)
|
||||
JHW._hasErrors = true
|
||||
|
95
vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js
vendored
Normal file
95
vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
(function() {
|
||||
if (!(typeof jasmine !== "undefined" && jasmine !== null)) {
|
||||
throw new Error("jasmine not loaded!");
|
||||
}
|
||||
jasmine.HeadlessConsoleReporter = (function() {
|
||||
function HeadlessConsoleReporter(callback) {
|
||||
this.callback = callback != null ? callback : null;
|
||||
this.results = [];
|
||||
this.failedCount = 0;
|
||||
this.length = 0;
|
||||
}
|
||||
HeadlessConsoleReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var output, result, resultLine, runtime, _i, _len, _ref;
|
||||
if (this.hasError()) {
|
||||
return;
|
||||
}
|
||||
if (window.JHW) {
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
runtime = (new Date() - this.startTime) / 1000.0;
|
||||
JHW.stdout.print("\n");
|
||||
resultLine = this._formatResultLine(runtime);
|
||||
if (this.failedCount === 0) {
|
||||
JHW.stdout.puts(("PASS: " + resultLine).foreground('green'));
|
||||
} else {
|
||||
JHW.stdout.puts(("FAIL: " + resultLine).foreground('red'));
|
||||
}
|
||||
output = "TOTAL||" + this.length + "||" + this.failedCount + "||" + runtime + "||" + (JHW._hasErrors ? "T" : "F");
|
||||
JHW.report.puts(output);
|
||||
_ref = this.results;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
result = _ref[_i];
|
||||
result.print();
|
||||
}
|
||||
return JHW.finishSuite();
|
||||
};
|
||||
HeadlessConsoleReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
this.startTime = new Date();
|
||||
return JHW.stdout.puts("\nRunning Jasmine specs...".bright());
|
||||
};
|
||||
HeadlessConsoleReporter.prototype.reportSpecResults = function(spec) {
|
||||
var failureResult, foundLine, result, results, testCount, _i, _len, _ref;
|
||||
if (this.hasError()) {
|
||||
return;
|
||||
}
|
||||
results = spec.results();
|
||||
this.length++;
|
||||
if (results.passed()) {
|
||||
JHW.stdout.print('.'.foreground('green'));
|
||||
return JHW.report.puts("PASS||" + spec.getJHWSpecInformation());
|
||||
} else {
|
||||
JHW.stdout.print('F'.foreground('red'));
|
||||
JHW.report.puts("FAIL||" + spec.getJHWSpecInformation());
|
||||
JHW.hasError();
|
||||
this.failedCount++;
|
||||
failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName());
|
||||
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);
|
||||
}
|
||||
};
|
||||
HeadlessConsoleReporter.prototype.reportSpecStarting = function(spec) {
|
||||
if (this.hasError()) {
|
||||
spec.finish();
|
||||
return spec.suite.finish();
|
||||
}
|
||||
};
|
||||
HeadlessConsoleReporter.prototype.reportSuiteResults = function(suite) {};
|
||||
HeadlessConsoleReporter.prototype.hasError = function() {
|
||||
return JHW._hasErrors;
|
||||
};
|
||||
HeadlessConsoleReporter.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(' ');
|
||||
};
|
||||
return HeadlessConsoleReporter;
|
||||
})();
|
||||
}).call(this);
|
@ -3,93 +3,7 @@
|
||||
throw new Error("jasmine not laoded!");
|
||||
}
|
||||
jasmine.HeadlessReporter = (function() {
|
||||
function HeadlessReporter(callback) {
|
||||
this.callback = callback != null ? callback : null;
|
||||
this.results = [];
|
||||
this.failedCount = 0;
|
||||
this.length = 0;
|
||||
}
|
||||
HeadlessReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var output, result, resultLine, runtime, _i, _len, _ref;
|
||||
if (this.hasError()) {
|
||||
return;
|
||||
}
|
||||
if (this.callback) {
|
||||
this.callback();
|
||||
}
|
||||
runtime = (new Date() - this.startTime) / 1000.0;
|
||||
JHW.stdout.print("\n");
|
||||
resultLine = this._formatResultLine(runtime);
|
||||
if (this.failedCount === 0) {
|
||||
JHW.stdout.puts(("PASS: " + resultLine).foreground('green'));
|
||||
} else {
|
||||
JHW.stdout.puts(("FAIL: " + resultLine).foreground('red'));
|
||||
}
|
||||
output = "TOTAL||" + this.length + "||" + this.failedCount + "||" + runtime + "||" + (JHW._hasErrors ? "T" : "F");
|
||||
JHW.report.puts(output);
|
||||
_ref = this.results;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
result = _ref[_i];
|
||||
result.print();
|
||||
}
|
||||
return JHW.finishSuite();
|
||||
};
|
||||
HeadlessReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
this.startTime = new Date();
|
||||
return JHW.stdout.puts("\nRunning Jasmine specs...".bright());
|
||||
};
|
||||
HeadlessReporter.prototype.reportSpecResults = function(spec) {
|
||||
var failureResult, foundLine, result, results, testCount, _i, _len, _ref;
|
||||
if (this.hasError()) {
|
||||
return;
|
||||
}
|
||||
results = spec.results();
|
||||
this.length++;
|
||||
if (results.passed()) {
|
||||
JHW.stdout.print('.'.foreground('green'));
|
||||
return JHW.report.puts("PASS||" + spec.getJHWSpecInformation());
|
||||
} else {
|
||||
JHW.stdout.print('F'.foreground('red'));
|
||||
JHW.report.puts("FAIL||" + spec.getJHWSpecInformation());
|
||||
JHW.hasError();
|
||||
this.failedCount++;
|
||||
failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName());
|
||||
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);
|
||||
}
|
||||
};
|
||||
HeadlessReporter.prototype.reportSpecStarting = function(spec) {
|
||||
if (this.hasError()) {
|
||||
spec.finish();
|
||||
return spec.suite.finish();
|
||||
}
|
||||
};
|
||||
HeadlessReporter.prototype.reportSuiteResults = function(suite) {};
|
||||
HeadlessReporter.prototype.hasError = function() {
|
||||
return JHW._hasErrors;
|
||||
};
|
||||
HeadlessReporter.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(' ');
|
||||
};
|
||||
function HeadlessReporter() {}
|
||||
return HeadlessReporter;
|
||||
})();
|
||||
}).call(this);
|
||||
|
Loading…
Reference in New Issue
Block a user