Class: RSpec::Core::Formatters::TextMateFormatter
- Inherits:
-
HtmlFormatter
- Object
- BaseFormatter
- BaseTextFormatter
- HtmlFormatter
- RSpec::Core::Formatters::TextMateFormatter
- Defined in:
- lib/rspec/core/formatters/text_mate_formatter.rb
Overview
Formats backtraces so they're clickable by TextMate
Constant Summary
Constants included from Helpers
Helpers::DEFAULT_PRECISION, Helpers::SUB_SECOND_PRECISION
Instance Attribute Summary
Attributes inherited from BaseFormatter
#duration, #example_count, #example_group, #examples, #failed_examples, #failure_count, #output, #pending_count, #pending_examples
Instance Method Summary collapse
- #backtrace_line(line, skip_textmate_conversion = false) ⇒ Object
- #extra_failure_content(exception) ⇒ Object
- #format_backtrace_line_for_textmate(line) ⇒ Object
Methods inherited from HtmlFormatter
#dump_failures, #dump_pending, #dump_summary, #example_failed, #example_group_number, #example_group_started, #example_number, #example_passed, #example_pending, #example_started, #initialize, #message, #percent_done, #start, #start_dump
Methods inherited from BaseTextFormatter
#close, #color_code_for, #colorise_summary, #colorize, const_missing, #dump_commands_to_rerun_failed_examples, #dump_failures, #dump_pending, #dump_profile, #dump_profile_slowest_example_groups, #dump_profile_slowest_examples, #dump_summary, #message, #seed, #summary_line
Methods inherited from BaseFormatter
#close, #dump_failures, #dump_pending, #dump_summary, #example_failed, #example_group_finished, #example_group_started, #example_passed, #example_pending, #example_started, #format_backtrace, #initialize, #message, #start, #start_dump, #stop
Methods included from Helpers
#format_duration, #format_seconds, #pluralize, #strip_trailing_zeroes
Methods included from BacktraceFormatter
Constructor Details
This class inherits a constructor from RSpec::Core::Formatters::HtmlFormatter
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RSpec::Core::Formatters::HtmlFormatter
Instance Method Details
#backtrace_line(line, skip_textmate_conversion = false) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/rspec/core/formatters/text_mate_formatter.rb', line 9 def backtrace_line(line, skip_textmate_conversion=false) if skip_textmate_conversion super(line) else format_backtrace_line_for_textmate(super(line)) end end |
#extra_failure_content(exception) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/rspec/core/formatters/text_mate_formatter.rb', line 24 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 |
#format_backtrace_line_for_textmate(line) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/rspec/core/formatters/text_mate_formatter.rb', line 17 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.($1)}&line=#{$2}\">#{$1}:#{$2}</a> " end end |