searls/jasmine-rails — pull request #112 by laser (2014-03-20 16:37:32+00:00)
Title: Computing failures must account for skipped or pending

# Problem

The `reportRunnerResults` method on the `ConsoleReporter` computes the total number of failed specs thusly:

```javascript
proto.reportRunnerResults = proto.jasmineDone = function(runner) {
var failed = this.executed_specs - this.passed_specs;
// ...
}
```

Since the `executed_specs` property is incremented via a call to `specDone` (from jasmine.js) when a spec is run, the value of `failed` will be non-zero if any specs had a status not equal to `passed`. The code in jasmine-runner.js, however, passes PhantomJS a status code of 1 only if one or more specs have been marked as `failed`. This combination causes the test suite to pass (from a status code perspective) while the ConsoleReporter displays a failure message.

```javascript
if(jsApiReporter.specs) {
jsApiReporter.specs().forEach(function(spec) {
if(spec.status === "failed") {
exitCode = 1;
}
})
}

setTimeout(function() {
window.callPhantom({
event: 'exit',
exitCode: exitCode
});
}, 1);
```

# Solution

This patch introduces a new status `skipped_or_pending` and corresponding counter that is incremented when `specDone` is called and the spec has not been marked as a success or failure. The value of `failed` consumes the value of this counter. The final message displayed to the user now communicates if any tests were `pending` or `skipped`.