类: RSpec::Matchers::BuiltIn::All 私有

继承
BaseMatcher 显示所有
定义于
lib/rspec/matchers/built_in/all.rb

概述

此类是私有 API 的一部分。 如果可能,请避免使用此类,因为它可能会在将来被移除或更改。

提供 all 的实现。不打算直接实例化。

常量摘要

BaseMatcher 继承的常量

BaseMatcher::UNDEFINED

实例方法摘要 折叠

BaseMatcher 继承的方法

#diffable?, #expects_call_stack_jump?, #match_unless_raises, #matches?, #supports_block_expectations?

BaseMatcher::DefaultFailureMessages 包含的方法

#failure_message_when_negated

Composable 包含的方法

#===, #and, #description_of, #or, should_enumerate?, surface_descriptions_in, unreadable_io?, #values_match?

构造函数详情

#initialize(matcher) ⇒All

此方法是私有 API 的一部分。 如果可能,请避免使用此方法,因为它可能会在将来被移除或更改。

返回 All 的新实例。

11
12
13
14
# File 'lib/rspec/matchers/built_in/all.rb', line 11
def initialize(matcher)
  @matcher = matcher
  @failed_objects = {}
end

实例方法详情

#descriptionString

此方法是私有 API 的一部分。 如果可能,请避免使用此方法,因为它可能会在将来被移除或更改。

返回

  • (String)
37
38
39
# File 'lib/rspec/matchers/built_in/all.rb', line 37
def description
  improve_hash_formatting "all #{description_of matcher}"
end

#failure_messageString

此方法是私有 API 的一部分。 如果可能,请避免使用此方法,因为它可能会在将来被移除或更改。

返回

  • (String)
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rspec/matchers/built_in/all.rb', line 23
def failure_message
  unless iterable?
    return "#{improve_hash_formatting(super)}, but was not iterable"
  end
  all_messages = [improve_hash_formatting(super)]
  failed_objects.each do |index, matcher_failure_message|
    all_messages << failure_message_for_item(index, matcher_failure_message)
  end
  all_messages.join("\n\n")
end