类: RSpec::Core::Example::ExecutionResult

继承
Object
  • Object
显示全部
定义在
lib/rspec/core/example.rb

概述

表示执行示例的结果。为了向后兼容,它表现得像一个哈希。

实例属性摘要 折叠

实例方法摘要 折叠

实例属性详细信息

#exceptionException?

返回 如果发生错误,则为错误。

返回

  • (Exception, nil)

    如果发生错误,则为错误。

563
564
565
# File 'lib/rspec/core/example.rb', line 563
def exception
  @exception
end

#finished_atTime

返回 示例完成时间。

返回

  • (Time)

    示例完成时间。

569
570
571
# File 'lib/rspec/core/example.rb', line 569
def finished_at
  @finished_at
end

#pending_exceptionException?

返回 执行待定示例时触发的异常。如果没有触发异常,则除非标记为 :skip,否则将不再获得 :pending 状态。

返回

  • (Exception, nil)

    执行待定示例时触发的异常。如果没有触发异常,则除非标记为 :skip,否则将不再获得 :pending 状态。

582
583
584
# File 'lib/rspec/core/example.rb', line 582
def pending_exception
  @pending_exception
end

#pending_fixedBoolean

返回 对于标记为 :pending 的示例,这表示它现在是否通过。

返回

  • (Boolean)

    对于标记为 :pending 的示例,这表示它现在是否通过。

586
587
588
# File 'lib/rspec/core/example.rb', line 586
def pending_fixed
  @pending_fixed
end

#pending_messageString?

返回 示例待定的原因,如果示例未待定则为 nil。

返回

  • (String, nil)

    示例待定的原因,如果示例未待定则为 nil。

576
577
578
# File 'lib/rspec/core/example.rb', line 576
def pending_message
  @pending_message
end

#run_timeFloat

返回 示例运行时间(以秒为单位)。

返回

  • (Float)

    示例运行时间(以秒为单位)。

572
573
574
# File 'lib/rspec/core/example.rb', line 572
def run_time
  @run_time
end

#started_atTime

返回 示例开始时间。

返回

  • (Time)

    示例开始时间。

566
567
568
# File 'lib/rspec/core/example.rb', line 566
def started_at
  @started_at
end

#statusSymbol

返回 :passed:failed:pending

返回

  • (Symbol)

    :passed:failed:pending

560
561
562
# File 'lib/rspec/core/example.rb', line 560
def status
  @status
end

实例方法详细信息

#ensure_timing_set(clock) ⇒void

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

如果尚未设置,则填充 finished_at 和 run_time

610
611
612
# File 'lib/rspec/core/example.rb', line 610
def ensure_timing_set(clock)
  calculate_run_time(clock.now) unless finished_at
end

#example_skipped?Boolean

返回 表示示例是否完全跳过(通常通过 :skip 元数据或 skip 方法实现)。跳过的示例将具有 :pending 结果。:pending 结果也可以来自标记为 :pending 的示例,这会导致它们运行,如果示例通过,则会产生 :failed 结果。

返回

  • (Boolean)

    表示示例是否完全跳过(通常通过 :skip 元数据或 skip 方法实现)。跳过的示例将具有 :pending 结果。:pending 结果也可以来自标记为 :pending 的示例,这会导致它们运行,如果示例通过,则会产生 :failed 结果。

597
598
599
# File 'lib/rspec/core/example.rb', line 597
def example_skipped?
  status == :pending && !pending_exception
end

#pending_fixed?Boolean

返回

  • (Boolean)
588
589
590
# File 'lib/rspec/core/example.rb', line 588
def pending_fixed?
  !!pending_fixed
end

#record_finished(status, finished_at) ⇒void

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

记录示例的完成状态。

603
604
605
606
# File 'lib/rspec/core/example.rb', line 603
def record_finished(status, finished_at)
  self.status = status
  calculate_run_time(finished_at)
end