testdouble / jasmine-rails

A Jasmine runner for rails projects that's got you covered in both the terminal and the browser
http://rubygems.org/gems/jasmine-rails
MIT License
377 stars 154 forks source link

ConsoleReporter displays failure message (yet exits with status code 0) if tests are marked as pending #112

Closed laser closed 10 years ago

laser commented 10 years ago

Problem

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

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.

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.

simeonwillbanks commented 10 years ago

:thumbsup: I'm seeing the same issue with pending specs. Thanks @laser!

laser commented 10 years ago

No problemo. Thanks for reviewing the patch.

searls commented 10 years ago

Looks good to me! Thanks!