Sha256: c565cebe1d200491f67c37ad945929f47d3ff5c06bed0ac3ba7c99a065109b02

Contents?: true

Size: 1.12 KB

Versions: 163

Compression:

Stored size: 1.12 KB

Contents

require 'cgi'
require 'rspec/core/formatters/html_formatter'

module RSpec
  module Core
    module Formatters
      # Formats backtraces so they're clickable by TextMate
      class TextMateFormatter < HtmlFormatter
        def backtrace_line(line, skip_textmate_conversion=false)
          if skip_textmate_conversion
            super(line)
          else
            format_backtrace_line_for_textmate(super(line))
          end
        end

        def format_backtrace_line_for_textmate(line)
          return nil unless line
          CGI.escapeHTML(line).sub(/([^:]*\.e?rb):(\d*)/) do
            "<a href=\"txmt://open?url=file://#{File.expand_path($1)}&line=#{$2}\">#{$1}:#{$2}</a> "
          end
        end

        def extra_failure_content(exception)
          require 'rspec/core/formatters/snippet_extractor'
          backtrace = exception.backtrace.map {|line| backtrace_line(line, :skip_textmate_conversion)}
          backtrace.compact!
          @snippet_extractor ||= SnippetExtractor.new
          "    <pre class=\"ruby\"><code>#{@snippet_extractor.snippet(backtrace)}</code></pre>"
        end
      end
    end
  end
end

Version data entries

163 entries across 108 versions & 19 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rspec-core-2.9.0/lib/rspec/core/formatters/text_mate_formatter.rb
classiccms-0.7.5 vendor/bundle/gems/rspec-core-2.10.0/lib/rspec/core/formatters/text_mate_formatter.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-core-2.9.0/lib/rspec/core/formatters/text_mate_formatter.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-core-2.10.0/lib/rspec/core/formatters/text_mate_formatter.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-core-2.9.0/lib/rspec/core/formatters/text_mate_formatter.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-core-2.10.0/lib/rspec/core/formatters/text_mate_formatter.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-core-2.13.0/lib/rspec/core/formatters/text_mate_formatter.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/formatters/text_mate_formatter.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/formatters/text_mate_formatter.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-core-2.10.0/lib/rspec/core/formatters/text_mate_formatter.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-core-2.9.0/lib/rspec/core/formatters/text_mate_formatter.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-core-2.10.0/lib/rspec/core/formatters/text_mate_formatter.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-core-2.9.0/lib/rspec/core/formatters/text_mate_formatter.rb
sshp-0.0.2 vendor/ruby/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/formatters/text_mate_formatter.rb
sshp-0.0.1 vendor/ruby/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/formatters/text_mate_formatter.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-core-2.9.0/lib/rspec/core/formatters/text_mate_formatter.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-core-2.10.0/lib/rspec/core/formatters/text_mate_formatter.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/formatters/text_mate_formatter.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/formatters/text_mate_formatter.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/rspec-core-2.13.0/lib/rspec/core/formatters/text_mate_formatter.rb