类: RSpec::Core::Example::Procsy
- 继承
-
Object
- Object
- RSpec::Core::Example::Procsy
- 定义于
- lib/rspec/core/example.rb
概述
注意
此类还公开 RSpec::Core::Example 的实例方法,通过代理传递给包装的 RSpec::Core::Example 实例。
包装了 Proc
和 RSpec::Core::Example,用于在 around 钩子中使用。在 around 钩子中,我们需要传递这种特殊类型的对象(而不是原始的 RSpec::Core::Example),因为当存在多个 around
钩子时,我们必须递归地包装它们。
实例属性摘要 折叠
-
#example ⇒ void 只读
The RSpec::Core::Example 实例。
实例方法摘要 折叠
-
#call(*args, &block) ⇒ void (也称: #run)
调用 proc 并记录该示例已执行。
-
#executed? ⇒ Boolean
指示 around 钩子是否已执行该示例。
-
#initialize(example, &block) ⇒ Procsy 构造函数
Procsy 的新实例。
-
#to_proc ⇒ void
提供一个包装的 proc,该 proc 将在执行时更新我们的
executed?
状态。
构造函数详细信息
#initialize(example, &block) ⇒Procsy
返回 Procsy 的新实例。
362 363 364 365 366 |
# File 'lib/rspec/core/example.rb', line 362 def initialize(example, &block) @example = example @proc = block @executed = false end |
实例属性详细信息
#example ⇒void (只读)
The RSpec::Core::Example 实例。
333 334 335 |
# File 'lib/rspec/core/example.rb', line 333 def example @example end |
实例方法详细信息
#call(*args, &block) ⇒void 也称: run
调用 proc 并记录该示例已执行。
350 351 352 353 |
# File 'lib/rspec/core/example.rb', line 350 def call(*args, &block) @executed = true @proc.call(*args, &block) end |
#executed? ⇒Boolean
指示 around 钩子是否已执行该示例。
374 375 376 |
# File 'lib/rspec/core/example.rb', line 374 def executed? @executed end |
#to_proc ⇒void
提供一个包装的 proc,该 proc 将在执行时更新我们的 executed?
状态。
358 359 360 |
# File 'lib/rspec/core/example.rb', line 358 def to_proc method(:call).to_proc end |