类: RSpec::Matchers::BuiltIn::Exist 私有

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

概述

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

exist 提供实现。不建议直接实例化。

定义在命名空间下

类: ExistenceTest

常量摘要

BaseMatcher 继承的常量

BaseMatcher::UNDEFINED

实例方法摘要 收起

BaseMatcher 继承的方法

#description, #diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?

Composable 包含的方法

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

构造函数详细信息

#initialize(*expected) ⇒Exist

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

返回 Exist 的新实例。

8
9
10
# File 'lib/rspec/matchers/built_in/exist.rb', line 8
def initialize(*expected)
  @expected = expected
end

实例方法详细信息

#does_not_match?(actual) ⇒Boolean

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

返回值

  • (Boolean)
22
23
24
25
26
# File 'lib/rspec/matchers/built_in/exist.rb', line 22
def does_not_match?(actual)
  @actual = actual
  @test = ExistenceTest.new @actual, @expected
  @test.valid_test? && !@test.actual_exists?
end

#failure_messageString

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

返回值

  • (String)
30
31
32
# File 'lib/rspec/matchers/built_in/exist.rb', line 30
def failure_message
  "expected #{actual_formatted} to exist#{@test.validity_message}"
end

#failure_message_when_negatedString

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

返回值

  • (String)
36
37
38
# File 'lib/rspec/matchers/built_in/exist.rb', line 36
def failure_message_when_negated
  "expected #{actual_formatted} not to exist#{@test.validity_message}"
end

#matches?(actual) ⇒Boolean

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

返回值

  • (Boolean)
14
15
16
17
18
# File 'lib/rspec/matchers/built_in/exist.rb', line 14
def matches?(actual)
  @actual = actual
  @test = ExistenceTest.new @actual, @expected
  @test.valid_test? && @test.actual_exists?
end