Sha256: 65b440d73e0f8e11c2d405a15484fbc1a75a7e28a7ec6f6a39b4e2c969b7da50

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

var Evergreen = {};

Evergreen.Spec = function(element) {
  var self = this;
  this.element = $(element);
  this.runLink = this.element.find('.run');
  this.runLink.click(function() {
    self.run()
    return false;
  });
}

Evergreen.Spec.prototype.run = function() {
  var self = this
  this.iframe = $('<iframe></iframe>').attr('src', this.runLink.attr('href')).appendTo(this.element)
  this.iframe.css({ position: 'absolute', left: '-20000px' });
  this.runLink.addClass('running').text('Running…');
  $(this.iframe).load(function() {
    var context = self.iframe.get(0).contentWindow;
    var evergreen = context.Evergreen;
    if(evergreen.done) {
      self.done(evergreen.results);
    } else {
      evergreen.onDone = function() {
        self.done(evergreen.results);
      }
    }
  });
}

Evergreen.Spec.prototype.done = function(results) {
  var failed = []
  $.each(results, function() {
    if(!this.passed) { failed.push(this); }
  });

  this.runLink.removeClass('running');

  if(failed.length) {
    this.runLink.addClass('fail').removeClass('pass').text('Fail')
  } else {
    this.runLink.addClass('pass').removeClass('fail').text('Pass')
  }
  this.iframe.remove();
}

$(function() {
  $('#specs li, #all').each(function() {
    new Evergreen.Spec(this)
  });
});

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
evergreen-1.3.0 lib/evergreen/resources/list.js
evergreen-1.2.0 lib/evergreen/resources/list.js
evergreen-1.1.3 lib/evergreen/resources/list.js
evergreen-1.1.2 lib/evergreen/resources/list.js
evergreen-1.1.0 lib/evergreen/resources/list.js
evergreen-1.0.1 lib/evergreen/resources/list.js
evergreen-1.0.0 lib/evergreen/resources/list.js
evergreen-1.0.0.rc lib/evergreen/resources/list.js