/ Published in: Ruby
Expand |
Embed | Plain Text
####### #Command : RUBYLIB="$TM_BUNDLE_SUPPORT/lib:$RUBYLIB" "${TM_RUBY:=ruby}" -- "${TM_BUNDLE_SUPPORT}/bin/spec_helper.rb" ####### #Your.bundle/Support/bin/spec_helper.rb : require 'cgi' #try and remove unnecessary '..'s from paths. #Eg collapse 'config/../app/controllers/../../public' to 'public'. Hopefully. def rationalize_path(path) components = path.split("/") real_components = [] components.each do |c| if (c == "..") && (real_components.size > 0) && (real_components.last != "..") real_components.pop else real_components.push c end end File.join(real_components) end Dir.chdir(ENV['TM_PROJECT_DIRECTORY']) output = `rake spec 2>&1` output = CGI.escapeHTML(output) #rationalize paths (strip out unnecessary '..'s etc) output.gsub! /(\.\/|\/)[^:\n&]+\.[^:\n]+/ do |m| rationalize_path(m) end #Find local file names and make them into proper links #It ignores any paths that don't start with './'. # (This is a feature, IMO - too many links otherwise) output.gsub! /\.(\/[^:&]+):([\d]+)/ do |m| path = Dir.pwd + $1 "<a href=\"txmt://open?url=file://#{path}&line=#{$2}\">#{m}</a>" end #Remove unnecessary repitition of the project path. #Need to keep it in if it's preceeded by '/' - this would indicate it's part of a link url. output.gsub! /([^\/])#{Dir.pwd}\// do |m| $1+'./' end #Find the result lines (x specification(s), y failure(s)) and color them output.gsub! /^[\d]+ specifications?, [\d]+ failures?/ do |m| "<span class='result'>#{m}</span>" end output.gsub!("\n", "<br/>") puts <<END <html> <head> <title>rspec results</title> <style type='text/css'> body {font-size:0.8em} .result {font-weight:bold;} </style> </head> <body> <h1>rspec</h1> #{output} </body> </html> END
You need to login to post a comment.
