类: RSpec::Expectations::ExpectationTarget

继承
Object
  • Object
显示全部
包含
实例方法
定义于
lib/rspec/expectations/expectation_target.rb

概述

注意

ExpectationTarget 不建议用户直接实例化。请使用 expect 代替。

包装期望的目标。

示例

expect(something)       # => ExpectationTarget wrapping something
expect { do_something } # => ExpectationTarget wrapping the block

# used with `to`
expect(actual).to eq(3)
# with `not_to`
expect(actual).not_to eq(3)

定义在命名空间下

模块: InstanceMethods

实例属性摘要 折叠

实例方法摘要 折叠

InstanceMethods 中包含的方法

#not_to, #to

构造函数详情

#initialize(value) ⇒ExpectationTarget

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

返回 ExpectationTarget 的新实例。

31
32
33
# File 'lib/rspec/expectations/expectation_target.rb', line 31
def initialize(value)
  @target = value
end

实例属性详情

#targetObject (只读)

注意

此名称与 Minitest::Expectation 一致,以便我们的 InstanceMethods 模块可以在 Minitest 上下文中被包含在该类中。

返回期望的目标。

返回

  • (Object)

    期望的目标

28
29
30
# File 'lib/rspec/expectations/expectation_target.rb', line 28
def target
  @target
end