异常: RSpec::Core::MultipleExceptionError
- 继承
-
StandardError
- Object
- StandardError
- RSpec::Core::MultipleExceptionError
- 定义于
- lib/rspec/core/formatters/exception_presenter.rb
概述
提供一个单一的异常实例,该实例提供对多个子异常的访问。这用于单个规范有多个异常的情况,例如 it
块中有一个异常,after
块中有一个异常。
实例属性摘要 折叠
-
#aggregation_block_label ⇒ nil 只读
仅为与
RSpec::Expectations::MultipleExpectationsNotMetError
的接口兼容性而提供。 -
#aggregation_metadata ⇒ Hash 只读
RSpec 用于格式化目的的元数据。
-
#all_exceptions ⇒ Array<Exception> 只读
失败和其他异常的列表,组合在一起。
-
#failures ⇒ Array<Exception> 只读
失败的列表。
-
#other_errors ⇒ Array<Exception> 只读
其他错误的列表。
实例方法摘要 折叠
-
#exception_count_description ⇒ void
返回 [String] 失败/错误计数的描述。
-
#initialize(*exceptions) ⇒ MultipleExceptionError 构造函数
MultipleExceptionError 的新实例。
-
#message ⇒ String
将所有异常消息组合成一个字符串。
-
#summary ⇒ String
失败的摘要,包括块标签和失败计数。
构造函数详细信息
#initialize(*exceptions) ⇒MultipleExceptionError
返回 MultipleExceptionError 的新实例。
519 520 521 522 523 524 525 526 527 528 529 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 519 def initialize(*exceptions) super() @failures = [] @other_errors = [] @all_exceptions = [] @aggregation_metadata = { :hide_backtrace => true } @aggregation_block_label = nil exceptions.each { |e| add e } end |
实例属性详细信息
#aggregation_block_label ⇒nil (只读)
返回 仅为与 RSpec::Expectations::MultipleExpectationsNotMetError
的接口兼容性而提供。
516 517 518 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 516 def aggregation_block_label @aggregation_block_label end |
#aggregation_metadata ⇒Hash (只读)
返回 RSpec 用于格式化目的的元数据。
512 513 514 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 512 def @aggregation_metadata end |
#all_exceptions ⇒Array<Exception> (只读)
返回 失败和其他异常的列表,组合在一起。
509 510 511 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 509 def all_exceptions @all_exceptions end |
#failures ⇒Array<Exception> (只读)
返回 失败的列表。
503 504 505 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 503 def failures @failures end |
#other_errors ⇒Array<Exception> (只读)
返回 其他错误的列表。
506 507 508 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 506 def other_errors @other_errors end |
实例方法详细信息
#exception_count_description ⇒void
返回 [String] 失败/错误计数的描述。
544 545 546 547 548 549 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 544 def exception_count_description failure_count = Formatters::Helpers.pluralize(failures.size, "failure") return failure_count if other_errors.empty? error_count = Formatters::Helpers.pluralize(other_errors.size, "other error") "#{failure_count} and #{error_count}" end |
#message ⇒String
注意
RSpec 实际上并没有使用它——而是分别格式化每个异常。
返回 将所有异常消息组合成一个字符串。
534 535 536 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 534 def all_exceptions.map(&:message).join("\n\n") end |
#summary ⇒String
返回 失败的摘要,包括块标签和失败计数。
539 540 541 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 539 def summary "Got #{exception_count_description}" end |