从TextMate运行Rails的RSpec
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从TextMate运行Rails的RSpec相关的知识,希望对你有一定的参考价值。
####### #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` #rationalize paths (strip out unnecessary '..'s etc) output.gsub! /(./|/)[^: &]+.[^: ]+/ 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!(" ", "<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
以上是关于从TextMate运行Rails的RSpec的主要内容,如果未能解决你的问题,请参考以下文章