spec/lib/jspec.js
function(input) {
      if (typeof input != 'string') return
      input = hookImmutable('preprocessing', input)
      return input.
        replace(/\t/g, '  ').
        replace(/\r\n|\n|\r/g, '\n').
        split('__END__')[0].
        replace(/([\w\.]+)\.(stub|destub)\((.*?)\)$/gm, '$2($1, $3)').
        replace(/describe\s+(.*?)$/gm, 'describe($1, function(){').
        replace(/^\s+it\s+(.*?)$/gm, ' it($1, function(){').
        replace(/^ *(before_each|after_each|before|after)(?= |\n|$)/gm, 'JSpec.currentSuite.addHook("$1", function(){').
        replace(/^\s*end(?=\s|$)/gm, '});').
        replace(/-\{/g, 'function(){').
        replace(/(\d+)\.\.(\d+)/g, function(_, a, b){ return range(a, b) }).
        replace(/\.should([_\.]not)?[_\.](\w+)(?: |;|$)(.*)$/gm, '.should$1_$2($3)').
        replace(/([\/\s]*)(.+?)\.(should(?:[_\.]not)?)[_\.](\w+)\((.*)\)\s*;?$/gm, '$1 expect($2).$3($4, $5)').
        replace(/, \)/g, ')').
        replace(/should\.not/g, 'should_not')
    }
function(input) {
      if (typeof input != 'string') return
      input = hookImmutable('preprocessing', input)
      return input.
        replace(/\t/g, '  ').
        replace(/\r\n|\n|\r/g, '\n').
        split('__END__')[0].
        replace(/([\w\.]+)\.(stub|destub)\((.*?)\)$/gm, '$2($1, $3)').
        replace(/describe\s+(.*?)$/gm, 'describe($1, function(){').
        replace(/^\s+it\s+(.*?)$/gm, ' it($1, function(){').
        replace(/^ *(before_each|after_each|before|after)(?= |\n|$)/gm, 'JSpec.currentSuite.addHook("$1", function(){').
        replace(/^\s*end(?=\s|$)/gm, '});').
        replace(/-\{/g, 'function(){').
        replace(/(\d+)\.\.(\d+)/g, function(_, a, b){ return range(a, b) }).
        replace(/\.should([_\.]not)?[_\.](\w+)(?: |;|$)(.*)$/gm, '.should$1_$2($3)').
        replace(/([\/\s]*)(.+?)\.(should(?:[_\.]not)?)[_\.](\w+)\((.*)\)\s*;?$/gm, '$1 expect($2).$3($4, $5)').
        replace(/, \)/g, ')').
        replace(/should\.not/g, 'should_not')
    }
function ( input ) { if ( typeof input != 'string' ) return input = hookImmutable ( 'preprocessing' , input ) return input . replace ( / \t / g , '  ' ) . replace ( / \r\n|\n|\r / g , '\n' ) . split ( '__END__' ) [ 0 ] . replace ( / ([\w\.]+)\.(stub|destub)\((.*?)\)$ / gm , '$2($1, $3)' ) . replace ( / describe\s+(.*?)$ / gm , 'describe($1, function(){' ) . replace ( / ^\s+it\s+(.*?)$ / gm , ' it($1, function(){' ) . replace ( / ^ *(before_each|after_each|before|after)(?= |\n|$) / gm , 'JSpec.currentSuite.addHook("$1", function(){' ) . replace ( / ^\s*end(?=\s|$) / gm , '});' ) . replace ( / -\{ / g , 'function(){' ) . replace ( / (\d+)\.\.(\d+) / g , function ( _ , a , b ) { return range ( a , b ) } ) . replace ( / \.should([_\.]not)?[_\.](\w+)(?: |;|$)(.*)$ / gm , '.should$1_$2($3)' ) . replace ( / ([\/\s]*)(.+?)\.(should(?:[_\.]not)?)[_\.](\w+)\((.*)\)\s*;?$ / gm , '$1 expect($2).$3($4, $5)' ) . replace ( / , \) / g , ')' ) . replace ( / should\.not / g , 'should_not' ) }
Pre-process a string of JSpec.

@param  {string} input
@return {string}
@api private
Pre - process a string of JSpec .