small clenaup and ensure form submits don't trigger loops, either

This commit is contained in:
John Bintz 2011-07-22 09:40:40 -04:00
parent d08fb1d445
commit 8a5121bd90
7 changed files with 66 additions and 23 deletions

View File

@ -13,7 +13,6 @@ class window.HeadlessReporterResult
JHW.printName(output)
for result in @results
do (result) =>
JHW.printResult(result)
_findSpecLine: ->
bestChoice = { accuracy: 0, file: null, lineNumber: null }
@ -56,7 +55,6 @@ class jasmine.HeadlessReporter
@length = 0
reportRunnerResults: (runner) ->
for result in @results
do (result) =>
result.print()
this.callback() if @callback
@ -73,7 +71,6 @@ class jasmine.HeadlessReporter
@failedCount++
failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName())
for result in results.getItems()
do (result) =>
if result.type == 'expect' and !result.passed_
failureResult.addResult(result.message)
@results.push(failureResult)

View File

@ -1,5 +1,4 @@
(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!");
}
@ -24,9 +23,7 @@
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
result = _ref[_i];
_results.push(__bind(function(result) {
return JHW.printResult(result);
}, this)(result));
_results.push(JHW.printResult(result));
}
return _results;
};
@ -90,14 +87,11 @@
this.length = 0;
}
HeadlessReporter.prototype.reportRunnerResults = function(runner) {
var result, _fn, _i, _len, _ref;
var result, _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];
_fn(result);
result.print();
}
if (this.callback) {
this.callback();
@ -108,7 +102,7 @@
return this.startTime = new Date();
};
HeadlessReporter.prototype.reportSpecResults = function(spec) {
var failureResult, result, results, _fn, _i, _len, _ref;
var failureResult, result, results, _i, _len, _ref;
results = spec.results();
this.length++;
if (results.passed()) {
@ -118,14 +112,11 @@
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];
_fn(result);
if (result.type === 'expect' && !result.passed_) {
failureResult.addResult(result.message);
}
}
return this.results.push(failureResult);
}

View File

@ -69,6 +69,15 @@ describe "jasmine-headless-webkit" do
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 == 1
report.should be_a_report_containing(2, 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

View File

@ -0,0 +1,5 @@
function yes() {
$('body').append('<form><button /><form>')
$('button').trigger('click')
}

View File

@ -0,0 +1,12 @@
src_files:
- spec/jasmine/leave_page/leave_page.js
spec_files:
- spec/jasmine/leave_page/leave_page_spec.js
src_dir: .
spec_dir: .
helpers:
- spec/javascripts/support/jquery-1.6.2.min.js

View File

@ -0,0 +1,11 @@
describe("something", function() {
it("should be true", function() {
yes();
expect(true).toEqual(true);
});
it("should so something else", function() {
expect(true).toEqual(true);
});
});

File diff suppressed because one or more lines are too long