Sha256: 647fd5cc3e09a44574c47df3982745ddb7e6a6bc30b79d2851549688ac56d779
Contents?: true
Size: 1.42 KB
Versions: 11
Compression:
Stored size: 1.42 KB
Contents
# Try to get the line number of a failed spec class window.HeadlessReporterResult constructor: (@name, @splitName) -> @results = [] addResult: (message) -> @results.push(message) toString: -> output = "\n" + @name.foreground('red') bestChoice = HeadlessReporterResult.findSpecLine(@splitName) output += " (#{bestChoice.file}:#{bestChoice.lineNumber})".foreground('blue') if bestChoice.file for result in @results line = result.message.foreground('red') if result.lineNumber line += " (line ~#{bestChoice.lineNumber + result.lineNumber})".foreground('red').bright() output += "\n #{line}" if result.line? output += "\n #{result.line}".foreground('yellow') output @findSpecLine: (splitName) -> bestChoice = { accuracy: 0, file: null, lineNumber: null } for file, lines of HeadlessReporterResult.specLineNumbers index = 0 lineNumber = 0 while newLineNumberInfo = lines[splitName[index]] if newLineNumberInfo.length == 0 lineNumber = newLineNumberInfo[0] else lastLine = null for line in newLineNumberInfo lastLine = line break if line > lineNumber lineNumber = lastLine index++ if index > bestChoice.accuracy bestChoice = { accuracy: index, file: file, lineNumber: lineNumber } break if index == splitName.length bestChoice
Version data entries
11 entries across 11 versions & 2 rubygems