<commit_before>var util = require("util");
var fs = require("fs");
var punch = require("../lib/punch.js");

describe("registering a renderer", function(){
  it("adds the renderer to registered renderers", function(){
    punch.registerRenderer("sample", "../spec/sample_renderer"); 

    expect(punch.registeredRenderers["sample"].name).toEqual("sample renderer");
  }); 
});

describe("registering a parser", function(){
  it("adds the parser to registered parsers", function(){
    punch.registerParser("sample", "../spec/sample_parser"); 

    expect(punch.registeredParsers["sample"].name).toEqual("sample parser");
  });
});

describe("returning an instance of renderer", function(){
  var fake_obj = jasmine.createSpy();
  punch.registeredRenderers["sample"] = fake_obj;

  expect(punch.rendererFor("sample") instanceof fake_obj).toBeTruthy();
});

describe("returning an instance of parser", function(){
  var fake_obj = jasmine.createSpy();
  punch.registeredParsers["sample"] = fake_obj;

  expect(punch.parserFor("sample") instanceof fake_obj).toBeTruthy();
});

describe("traversing templates", function() {

  it("traverses recursively", function(){
    var config = {"template_dir": "templates"}; 

    spyOn(fs, 'readdir').andCallFake(function(path, callback){
      if(fs.readdir.mostRecentCall.args[0] === "templates"){
        callback(null, ["index.mustache", "sub_dir"]); 
      } else {
        callback(null, ["sub.mustache"]); 
      }
    });
<commit_msg>Modified the names of spies in previous 2 tests<commit_after>var util = require("util");
var fs = require("fs");
var punch = require("../lib/punch.js");

describe("registering a renderer", function(){
  it("adds the renderer to registered renderers", function(){
    punch.registerRenderer("sample", "../spec/sample_renderer"); 

    expect(punch.registeredRenderers["sample"].name).toEqual("sample renderer");
  }); 
});

describe("registering a parser", function(){
  it("adds the parser to registered parsers", function(){
    punch.registerParser("sample", "../spec/sample_parser"); 

    expect(punch.registeredParsers["sample"].name).toEqual("sample parser");
  });
});

describe("returning an instance of renderer", function(){
  var fake_renderer = jasmine.createSpy();
  punch.registeredRenderers["sample"] = fake_renderer;

  expect(punch.rendererFor("sample") instanceof fake_renderer).toBeTruthy();
});

describe("returning an instance of parser", function(){
  var fake_parser = jasmine.createSpy();
  punch.registeredParsers["sample"] = fake_parser;

  expect(punch.parserFor("sample") instanceof fake_parser).toBeTruthy();
});

describe("traversing templates", function() {

  it("traverses recursively", function(){
    var config = {"template_dir": "templates"}; 

    spyOn(fs, 'readdir').andCallFake(function(path, callback){
      if(fs.readdir.mostRecentCall.args[0] === "templates"){
        callback(null, ["index.mustache", "sub_dir"]); 
      } else {
        callback(null, ["sub.mustache"]); 
      }
    });

{'fraction_non_alphanumeric': 0.17252820172528202, 'fraction_numerical': 0.0009953550099535502, 'mean_word_length': 5.066398390342052, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '1633567', 'n_tokens_mistral': 923, 'n_tokens_neox': 895, 'n_words': 184}