类:RSpec::Core::Formatters::BaseTextFormatter

继承
BaseFormatter
  • Object
显示全部
定义于
lib/rspec/core/formatters/base_text_formatter.rb

概述

所有 RSpec 内置格式化程序的基类。查看 RSpec::Core::Formatters::BaseFormatter 了解更多关于报告器调用的所有方法。

实例属性摘要

BaseFormatter 继承的属性

#example_group, #output

实例方法摘要 折叠

BaseFormatter 继承的方法

#example_group_started, #initialize, #start

构造函数详情

此类从 RSpec::Core::Formatters::BaseFormatter 继承构造函数

实例方法详情

#close(_notification) ⇒void

在套件运行结束时调用。允许格式化程序进行任何整理,但请注意,格式化程序输出流可能在其他地方使用,因此不要实际关闭它们。

参数

  • _notification (NullNotification)

    (忽略)

65
66
67
68
69
70
71
# File 'lib/rspec/core/formatters/base_text_formatter.rb', line 65
def close(_notification)
  return if output.closed?
  output.puts
  output.flush
end

#dump_failures(notification) ⇒void

转储每个示例失败的详细信息。

参数

  • notification (NullNotification)
30
31
32
33
# File 'lib/rspec/core/formatters/base_text_formatter.rb', line 30
def dump_failures(notification)
  return if notification.failure_notifications.empty?
  output.puts notification.fully_formatted_failed_examples
end

#dump_summary(summary) ⇒void

此方法在转储示例和失败后调用。每个参数都分配给相应的属性。

参数

  • summary (SummaryNotification)

    包含 duration、example_count、failure_count 和 pending_count

42
43
44
# File 'lib/rspec/core/formatters/base_text_formatter.rb', line 42
def dump_summary(summary)
  output.puts summary.fully_formatted
end

#message(notification) ⇒void

用于报告器将消息发送到输出流。

参数

  • notification (MessageNotification)

    包含消息

21
22
23
# File 'lib/rspec/core/formatters/base_text_formatter.rb', line 21
def message(notification)
  output.puts notification.message
end