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

继承
Struct
  • Object
显示全部
定义在
lib/rspec/matchers/built_in/exist.rb

概述

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

用于记忆此匹配器实际值/预期值的简单类,并检查匹配

实例属性摘要 折叠

实例方法摘要 折叠

实例属性详细信息

#actualObject

返回属性 actual 的值

返回

  • (Object)

    actual 的当前值

43
44
45
# File 'lib/rspec/matchers/built_in/exist.rb', line 43
def actual
  @actual
end

#expectedObject

返回属性 expected 的值

返回

  • (Object)

    expected 的当前值

43
44
45
# File 'lib/rspec/matchers/built_in/exist.rb', line 43
def expected
  @expected
end

实例方法详细信息

#actual_exists?Boolean

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

返回

  • (Boolean)
52
53
54
# File 'lib/rspec/matchers/built_in/exist.rb', line 52
def actual_exists?
  existence_values.first
end

#valid_test?Boolean

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

返回

  • (Boolean)
46
47
48
# File 'lib/rspec/matchers/built_in/exist.rb', line 46
def valid_test?
  uniq_truthy_values.size == 1
end

#validity_messageString

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

返回

  • (String)
58
59
60
61
62
63
64
65
66
67
# File 'lib/rspec/matchers/built_in/exist.rb', line 58
def validity_message
  case uniq_truthy_values.size
  when 0
    " but it does not respond to either `exist?` or `exists?`"
  when 2
    " but `exist?` and `exists?` returned different values:\n\n"\
    " exist?: #{existence_values.first}\n"\
    "exists?: #{existence_values.last}"
  end
end