类: RSpec::Matchers::BuiltIn::Match 私有

继承
BaseMatcher 显示全部
定义于
lib/rspec/matchers/built_in/match.rb

概述

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

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

常量摘要

BaseMatcher 继承的常量

BaseMatcher::UNDEFINED

实例方法摘要 折叠

BaseMatcher 继承的方法

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

BaseMatcher::DefaultFailureMessages 包含的方法

#failure_message, #failure_message_when_negated

Composable 包含的方法

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

构造函数详情

#initialize(expected) ⇒Match

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

返回 Match 的新实例。

8
9
10
11
12
# File 'lib/rspec/matchers/built_in/match.rb', line 8
def initialize(expected)
  super(expected)
  @expected_captures = nil
end

实例方法详情

#descriptionString

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

返回

  • (String)
15
16
17
18
19
20
21
# File 'lib/rspec/matchers/built_in/match.rb', line 15
def description
  if @expected_captures && @expected.match(actual)
    "match #{surface_descriptions_in(expected).inspect} with captures #{surface_descriptions_in(@expected_captures).inspect}"
  else
    "match #{surface_descriptions_in(expected).inspect}"
  end
end

#diffable?Boolean

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

返回

  • (Boolean)
25
26
27
# File 'lib/rspec/matchers/built_in/match.rb', line 25
def diffable?
  true
end

#with_captures(*captures) ⇒self

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

用于指定我们匹配的捕获

返回

  • (self)
31
32
33
34
# File 'lib/rspec/matchers/built_in/match.rb', line 31
def with_captures(*captures)
  @expected_captures = captures
  self
end