<commit_before>(function() {

// save the ajax method in case a test messes with it
Screw.ajax = jQuery.ajax;

$.extend(Screw.Specifications, {
  use_fixture: function(fixture_name) {
    Screw.Specifications.before(function() {
      $("#fixture_container").html(window.fixture_container[fixture_name]);
    });
  }
});

window.require = function() {
  // require is a NOOP in javascript.
  // the require statement is only "used" by the screw_server.rb when generating the wrapper html.
  // the screw_server looks for require statements per regexp.
};

var exampleName = function(element){
  var exampleName = $.trim($(element).children("h2").text());

  var names = contextNamesForExample(element);
  names.push(exampleName);

  return names.join(" ");
};

var contextNamesForExample = function(element){
  var describes = $(element).parents('.describe').children('h1');

  var contextNames = $.map(describes, function(context){
    return $.trim($(context).text());
  });

  return contextNames.reverse();
};

$(Screw).bind('loaded', function() {
  $('.it')
    .bind('failed', function(e, reason) {
      if (!window.console || !window.console.debug) { return; }
      console.debug("Failure:");
      console.debug(exampleName(this));
      console.debug(reason.toString());

      var file = reason.fileName || reason.sourceURL;
      var line = reason.lineNumber || reason.line;
      if (file || line) {
        console.debug('line ' + line + ', ' + file);
      }
      var trace = reason.stack;
      if (trace) {
        console.debug(trace);
      }
    })
    .bind('failed', function(e, reason) {
      var trace = reason.stack;
      if (trace) {
        var trace_lines = trace.split("\n")
        var test_dom = $(this);
        $.each(trace_lines, function(number, line) {
          test_dom.append($('<p class="error"></p>').text(line));
        });
      }
    })
});

}());<commit_msg>[screw-server] now automatically scrolls to first failed test<commit_after>(function() {

// save the ajax method in case a test messes with it
Screw.ajax = jQuery.ajax;

$.extend(Screw.Specifications, {
  use_fixture: function(fixture_name) {
    Screw.Specifications.before(function() {
      $("#fixture_container").html(window.fixture_container[fixture_name]);
    });
  }
});

window.require = function() {
  // require is a NOOP in javascript.
  // the require statement is only "used" by the screw_server.rb when generating the wrapper html.
  // the screw_server looks for require statements per regexp.
};

var exampleName = function(element){
  var exampleName = $.trim($(element).children("h2").text());

  var names = contextNamesForExample(element);
  names.push(exampleName);

  return names.join(" ");
};

var contextNamesForExample = function(element){
  var describes = $(element).parents('.describe').children('h1');

  var contextNames = $.map(describes, function(context){
    return $.trim($(context).text());
  });

  return contextNames.reverse();
};

$(Screw).bind('loaded', function() {
  $('.it')
    .bind('failed', function(e, reason) {
      if (!window.console || !window.console.debug) { return; }
      console.debug("Failure:");
      console.debug(exampleName(this));
      console.debug(reason.toString());

      var file = reason.fileName || reason.sourceURL;
      var line = reason.lineNumber || reason.line;
      if (file || line) {
        console.debug('line ' + line + ', ' + file);
      }
      var trace = reason.stack;
      if (trace) {
        console.debug(trace);
      }
    })
    .bind('failed', function(e, reason) {
      var trace = reason.stack;
      if (trace) {
        var trace_lines = trace.split("\n")
        var test_dom = $(this);
        $.each(trace_lines, function(number, line) {
          test_dom.append($('<p class="error"></p>').text(line));
        });
      }
    });

  $(Screw)
    .bind('after', function() {
      var failures = $("li .it.failed");
      if (failures.length > 0) {
        window.scrollTo(0, failures.first().position().top);
      }
    })

});

}());
{'fraction_non_alphanumeric': 0.16995073891625614, 'fraction_numerical': 0.001477832512315271, 'mean_word_length': 3.1061678463094036, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3255219', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1221, 'n_words': 273}