Method: RSpec::Core::Formatters::HtmlSnippetExtractor#snippet

Defined in:
lib/rspec/core/formatters/html_snippet_extractor.rb

#snippet(backtrace) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Extract lines of code corresponding to a backtrace.

Parameters:

  • backtrace (String)

    the backtrace from a test failure

Returns:

  • (String)

    highlighted code snippet indicating where the test failure occurred

See Also:

[View source]

49
50
51
52
53
# File 'lib/rspec/core/formatters/html_snippet_extractor.rb', line 49

def snippet(backtrace)
  raw_code, line = snippet_for(backtrace[0])
  highlighted = @@converter.convert(raw_code)
  post_process(highlighted, line)
end