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
#current_indentation, #dump_failures, #dump_pending, #dump_summary, #example_failed, #example_group_number, #example_group_started, #example_number, #example_passed, #example_pending, #example_started, #global_scripts, #global_styles, #html_header, #initialize, #message, #move_progress, #percent_done, #report_header, #start, #start_dump
Methods inherited from BaseTextFormatter
#close, #colorise_summary, #dump_commands_to_rerun_failed_examples, #dump_failures, #dump_pending, #dump_profile, #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, relative_path, #seed, #start, #start_dump, #stop
Methods included from Helpers
#format_seconds, #strip_trailing_zeroes
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 |