类: RSpec::Core::Formatters::BaseFormatter

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

概述

RSpec 的内置格式化器都是 RSpec::Core::Formatters::BaseFormatter 的子类。

直接已知子类

BaseTextFormatter

实例属性摘要 收起

实例方法摘要 收起

构造函数详情

#initialize(output) ⇒BaseFormatter

返回 BaseFormatter 的一个新实例。

参数

  • output (IO)

    格式化器输出

另请参阅

23
24
25
26
# File 'lib/rspec/core/formatters/base_formatter.rb', line 23
def initialize(output)
  @output = output || StringIO.new
  @example_group = nil
end

实例属性详情

#example_groupvoid

返回属性 example_group 的值。

17
18
19
# File 'lib/rspec/core/formatters/base_formatter.rb', line 17
def example_group
  @example_group
end

#outputvoid (只读)

返回属性 output 的值。

18
19
20
# File 'lib/rspec/core/formatters/base_formatter.rb', line 18
def output
  @output
end

实例方法详情

#close(_notification) ⇒void

参数

  • _notification (NullNotification)

    (忽略)

另请参阅

50
51
52
# File 'lib/rspec/core/formatters/base_formatter.rb', line 50
def close(_notification)
  restore_sync_output
end

#example_group_started(notification) ⇒void

参数

  • notification (GroupNotification)

    包含 example_group 的 RSpec::Core::ExampleGroup 子类

另请参阅

42
43
44
# File 'lib/rspec/core/formatters/base_formatter.rb', line 42
def example_group_started(notification)
  @example_group = notification.group
end

#start(notification) ⇒void

参数

  • notification (StartNotification)

另请参阅

32
33
34
35
# File 'lib/rspec/core/formatters/base_formatter.rb', line 32
def start(notification)
  start_sync_output
  @example_count = notification.count
end