Class: RSpec::Core::Formatters::ExceptionPresenter::Factory Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Classes:
| |
Inherits: | Object |
Defined in: | rspec-core/lib/rspec/core/formatters/exception_presenter.rb |
Overview
Configuring the ::RSpec::Core::Formatters::ExceptionPresenter
with the right set of options to handle pending vs failed vs skipped and aggregated (or not) failures is not simple. This class takes care of building an appropriate ::RSpec::Core::Formatters::ExceptionPresenter
for the provided example.
Class Method Summary
- .new(example) ⇒ Factory constructor private Internal use only
Instance Method Summary
- #build Internal use only
- #multiple_exception_summarizer(exception, prior_detail_formatter, color) private Internal use only
- #multiple_exceptions_error?(exception) ⇒ Boolean private Internal use only
- #options private Internal use only
- #pending_options private Internal use only
- #sub_failure_list_formatter(exception, message_color) private Internal use only
- #with_multiple_error_options_as_needed(exception, options) private Internal use only
Instance Method Details
#build
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 313
def build ExceptionPresenter.new(@exception, @example, ) end
#multiple_exception_summarizer(exception, prior_detail_formatter, color) (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 374
def multiple_exception_summarizer(exception, prior_detail_formatter, color) lambda do |example, colorizer| summary = if exception. [:hide_backtrace] # Since the backtrace is hidden, the subfailures will come # immediately after this, and using `:` will read well. "Got #{exception.exception_count_description}:" else # The backtrace comes after this, so using a `:` doesn't make sense # since the failures may be many lines below. "#{exception.summary}." end summary = colorizer.wrap(summary, color || RSpec.configuration.failure_color) return summary unless prior_detail_formatter [ prior_detail_formatter.call(example, colorizer), summary ] end end
#multiple_exceptions_error?(exception) ⇒ Boolean
(private)
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 370
def multiple_exceptions_error?(exception) MultipleExceptionError::InterfaceTag === exception end
#options (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 329
def (@exception, || {}) end
#pending_options (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 333
def if @execution_result.pending_fixed? { :description => "#{@example.full_description} FIXED", : => RSpec.configuration.fixed_color, :failure_lines => [ "Expected pending '#{@execution_result.}' to fail. No error was raised." ] } elsif @execution_result.status == :pending = { : => RSpec.configuration.pending_color, :detail_formatter => PENDING_DETAIL_FORMATTER } if RSpec.configuration.pending_failure_output == :no_backtrace [:backtrace_formatter] = EmptyBacktraceFormatter end end end
#sub_failure_list_formatter(exception, message_color) (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 395
def sub_failure_list_formatter(exception, ) common_backtrace_truncater = CommonBacktraceTruncater.new(exception) lambda do |failure_number, colorizer| FlatMap.flat_map(exception.all_exceptions.each_with_index) do |failure, index| = ( failure, :description => nil, :indentation => 0, : => || RSpec.configuration.failure_color, :skip_shared_group_trace => true ) failure = common_backtrace_truncater.with_truncated_backtrace(failure) presenter = ExceptionPresenter.new(failure, @example, ) presenter.fully_formatted_lines( "#{failure_number ? "#{failure_number}." : ''}#{index + 1}", colorizer ) end end end
#with_multiple_error_options_as_needed(exception, options) (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 354
def (exception, ) return unless multiple_exceptions_error?(exception) = .merge( :failure_lines => [], :extra_detail_formatter => sub_failure_list_formatter(exception, [: ]), :detail_formatter => multiple_exception_summarizer(exception, [:detail_formatter], [: ]) ) return unless exception. [:hide_backtrace] [:backtrace_formatter] = EmptyBacktraceFormatter end