All,
I’ve found that the html view for the rspec formatter falls to pieces
with
Rails 2.02 and rspec 1.10. Has anyone else run into this trouble?
Here’s a monkey patch that fixes the problem. A more elegant fix would
be
in order, but this gets the job done:
Index:
/Users/timcharper/www/exchange/vendor/plugins/rspec/lib/spec/runner/formatter/text_mate_formatter.rb
/Users/timcharper/www/exchange/vendor/plugins/rspec/lib/spec/runner/formatter/text_mate_formatter.rb
(revision 906)
+++
/Users/timcharper/www/exchange/vendor/plugins/rspec/lib/spec/runner/formatter/text_mate_formatter.rb
(working copy)
@@ -6,8 +6,9 @@
# Formats backtraces so they’re clickable by TextMate
class TextMateFormatter < HtmlFormatter
def backtrace_line(line)
-
line.gsub(/([^:]*\.rb):(\d*)/) do
-
"<a
href=“txmt://open?url=file://#{File.expand_path($1)}&line=#{$2}”>#{$1}:#{$2}
"
-
line.gsub!(/^(On line #([0-9]+) of )(.+)$/) {
“app/views/#{$3}:#{$2}”}
-
line.gsub(/([^:]*\.(rb|rhtml|erb)):(\d*)/) do
-
"<a
href=“txmt://open?url=file://#{File.expand_path($1)}&line=#{$3}”>#{$1}:#{$3}
"
end
end
end
Index:
/Users/timcharper/www/exchange/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb
/Users/timcharper/www/exchange/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb
(revision 906)
+++
/Users/timcharper/www/exchange/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb
(working copy)
@@ -88,6 +88,7 @@
def format_backtrace(backtrace)
return "" if backtrace.nil?
-
backtrace = backtrace.first.split("\n").map { |l| h(l).strip
}
backtrace.map { |line| backtrace_line(line) }.join("\n")
end
Tim