Class: RSpec::Core::Formatters::ExceptionPresenter
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb
Defined Under Namespace
Classes: Factory
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#example ⇒ Object
readonly
Returns the value of attribute example.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
Instance Method Summary collapse
- #colorized_formatted_backtrace(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒ Object
- #colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒ Object
- #formatted_backtrace(exception = @exception) ⇒ Object
-
#formatted_cause(_) ⇒ Object
:nocov:.
- #fully_formatted(failure_number, colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒ Object
- #fully_formatted_lines(failure_number, colorizer) ⇒ Object
-
#initialize(exception, example, options = {}) ⇒ ExceptionPresenter
constructor
A new instance of ExceptionPresenter.
- #message_lines ⇒ Object
Constructor Details
#initialize(exception, example, options = {}) ⇒ ExceptionPresenter
Returns a new instance of ExceptionPresenter.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb', line 16 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) @failure_lines = [:failure_lines] end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb', line 12 def description @description end |
#example ⇒ Object (readonly)
Returns the value of attribute example.
12 13 14 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb', line 12 def example @example end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
12 13 14 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb', line 12 def exception @exception end |
Instance Method Details
#colorized_formatted_backtrace(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒ Object
73 74 75 76 77 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb', line 73 def colorized_formatted_backtrace(colorizer=::RSpec::Core::Formatters::ConsoleCodes) formatted_backtrace.map do |backtrace_info| colorizer.wrap "# #{backtrace_info}", RSpec.configuration.detail_color end end |
#colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒ Object
33 34 35 36 37 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb', line 33 def (colorizer=::RSpec::Core::Formatters::ConsoleCodes) add_shared_group_lines(failure_lines, colorizer).map do |line| colorizer.wrap line, end end |
#formatted_backtrace(exception = @exception) ⇒ Object
39 40 41 42 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb', line 39 def formatted_backtrace(exception=@exception) backtrace_formatter.format_backtrace(exception.backtrace, example.) + formatted_cause(exception) end |
#formatted_cause(_) ⇒ Object
:nocov:
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb', line 67 def formatted_cause(exception) last_cause = final_exception(exception, [exception]) cause = [] if exception.cause cause << '------------------' cause << '--- Caused by: ---' cause << "#{exception_class_name(last_cause)}:" unless exception_class_name(last_cause) =~ /RSpec/ encoded_string((last_cause)).split("\n").each do |line| cause << " #{line}" end unless last_cause.backtrace.nil? || last_cause.backtrace.empty? cause << (" #{backtrace_formatter.format_backtrace(last_cause.backtrace, example.).first}") end end cause end |
#fully_formatted(failure_number, colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒ Object
79 80 81 82 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb', line 79 def fully_formatted(failure_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes) lines = fully_formatted_lines(failure_number, colorizer) lines.join("\n") << "\n" end |
#fully_formatted_lines(failure_number, colorizer) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb', line 84 def fully_formatted_lines(failure_number, colorizer) lines = [ encoded_description(description), detail_formatter.call(example, colorizer), (colorizer), extra_detail_formatter.call(failure_number, colorizer), ].compact.flatten lines = indent_lines(lines, failure_number) lines.unshift("") lines end |
#message_lines ⇒ Object
29 30 31 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb', line 29 def add_shared_group_lines(failure_lines, Notifications::NullColorizer) end |