Class: RSpec::Core::Formatters::ExceptionPresenter
- Inherits:
-
Object
- Object
- RSpec::Core::Formatters::ExceptionPresenter
- Defined in:
- lib/super_diff/rspec/monkey_patches.rb
Constant Summary collapse
- RESET_CODE =
UPDATE: Copy from SyntaxHighlighter::CodeRayImplementation
"\e[0m"
Instance Method Summary collapse
-
#colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒ Object
Override to only color uncolored lines in red.
-
#initialize(exception, example, options = {}) ⇒ ExceptionPresenter
constructor
A new instance of ExceptionPresenter.
Constructor Details
#initialize(exception, example, options = {}) ⇒ ExceptionPresenter
Returns a new instance of ExceptionPresenter.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/super_diff/rspec/monkey_patches.rb', line 82 def initialize(exception, example, ={}) @exception = exception @example = example @message_color = .fetch(:message_color) { RSpec.configuration.failure_color } @description = .fetch(:description) { example.full_description } @detail_formatter = .fetch(:detail_formatter) { Proc.new {} } @extra_detail_formatter = .fetch(:extra_detail_formatter) { Proc.new {} } @backtrace_formatter = .fetch(:backtrace_formatter) { RSpec.configuration.backtrace_formatter } @indentation = .fetch(:indentation, 2) @skip_shared_group_trace = .fetch(:skip_shared_group_trace, false) # Patch to convert options[:failure_lines] to groups if .include?(:failure_lines) @failure_line_groups = { lines: [:failure_lines], already_colored: false } end end |
Instance Method Details
#colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒ Object
Override to only color uncolored lines in red
102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/super_diff/rspec/monkey_patches.rb', line 102 def (colorizer=::RSpec::Core::Formatters::ConsoleCodes) lines = failure_line_groups.flat_map do |group| if group[:already_colored] group[:lines] else group[:lines].map do |line| colorizer.wrap(line, ) end end end add_shared_group_lines(lines, colorizer) end |