类: RSpec::Matchers::MultiMatcherDiff 私有
- 继承
-
Object
- Object
- RSpec::Matchers::MultiMatcherDiff
- 定义于
- lib/rspec/matchers/multi_matcher_diff.rb
概述
此类属于私有 API 的一部分。 应尽可能避免使用此类,因为它可能在将来被移除或更改。
当需要渲染多个差异时,处理预期值和实际值对的列表。还可以处理一对。
类方法摘要 折叠
-
.for_many_matchers(matchers) ⇒ RSpec::Matchers::MultiMatcherDiff 私有
将提供的匹配器列表封装在 MultiMatcherDiff 的实例中。
-
.from(expected, actual) ⇒ RSpec::Matchers::MultiMatcherDiff 私有
将提供的预期值封装在 MultiMatcherDiff 的实例中。
实例方法摘要 折叠
-
#initialize(expected_list) ⇒ MultiMatcherDiff 构造函数 私有
MultiMatcherDiff 的一个新实例。
-
#message_with_diff(message, differ) ⇒ String 私有
如果存在,则返回带有差异的附加消息,以用于提供的差异工厂和实际值。
构造函数详细信息
#initialize(expected_list) ⇒MultiMatcherDiff
此方法属于私有 API 的一部分。 应尽可能避免使用此方法,因为它可能在将来被移除或更改。
返回一个新的 MultiMatcherDiff 实例。
16 17 18 |
# File 'lib/rspec/matchers/multi_matcher_diff.rb', line 16 def initialize(expected_list) @expected_list = expected_list end |
类方法详细信息
.for_many_matchers(matchers) ⇒RSpec::Matchers::MultiMatcherDiff
此方法属于私有 API 的一部分。 应尽可能避免使用此方法,因为它可能在将来被移除或更改。
将提供的匹配器列表封装在 MultiMatcherDiff 的实例中。
37 38 39 |
# File 'lib/rspec/matchers/multi_matcher_diff.rb', line 37 def self.for_many_matchers(matchers) new(matchers.map { |m| [m.expected, diff_label_for(m), m.actual] }) end |
.from(expected, actual) ⇒RSpec::Matchers::MultiMatcherDiff
此方法属于私有 API 的一部分。 应尽可能避免使用此方法,因为它可能在将来被移除或更改。
将提供的预期值封装在 MultiMatcherDiff 的实例中。如果提供的 value 已经是 MultiMatcherDiff,则直接返回它。
27 28 29 30 |
# File 'lib/rspec/matchers/multi_matcher_diff.rb', line 27 def self.from(expected, actual) return expected if self === expected new([[expected, DEFAULT_DIFF_LABEL, actual]]) end |
实例方法详细信息
#message_with_diff(message, differ) ⇒String
此方法属于私有 API 的一部分。 应尽可能避免使用此方法,因为它可能在将来被移除或更改。
如果存在,则返回带有差异的附加消息,以用于提供的差异工厂和实际值
47 48 49 50 51 |
# File 'lib/rspec/matchers/multi_matcher_diff.rb', line 47 def (, differ) diff = diffs(differ) = "#{}\n#{diff}" unless diff.empty? end |