类: RSpec::Core::Notifications::ExamplesNotification

继承
Object
  • Object
显示所有
定义在
lib/rspec/core/notifications.rb

概述

ExamplesNotification 代表由报告器发送的包含关于套件示例信息的通知。

示例

def stop(notification)
  puts "Hey I ran #{notification.examples.size}"
end

实例方法概要 折叠

构造函数详细信息

#initialize(reporter) ⇒ExamplesNotification

返回 ExamplesNotification 的新实例。

70
71
72
# File 'lib/rspec/core/notifications.rb', line 70
def initialize(reporter)
  @reporter = reporter
end

实例方法详细信息

#examplesArray<RSpec::Core::Example>

返回示例列表。

返回值

75
76
77
# File 'lib/rspec/core/notifications.rb', line 75
def examples
  @reporter.examples
end

#failed_examplesArray<RSpec::Core::Example>

返回失败示例列表。

返回值

80
81
82
# File 'lib/rspec/core/notifications.rb', line 80
def failed_examples
  @reporter.failed_examples
end

#failure_notificationsArray<RSpec::Core::Notifications::FailedExampleNotification>

返回失败示例作为通知

返回值

97
98
99
# File 'lib/rspec/core/notifications.rb', line 97
def failure_notifications
  @failed_notifications ||= format_examples(failed_examples)
end

#fully_formatted_failed_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒String

返回失败示例列表,以 RSpec 内置格式化程序的输出方式完全格式化。

返回值

  • (String)

    失败示例列表,以 RSpec 内置格式化程序的输出方式完全格式化。

110
111
112
113
114
115
116
117
118
# File 'lib/rspec/core/notifications.rb', line 110
def fully_formatted_failed_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
  formatted = "\nFailures:\n"
  failure_notifications.each_with_index do |failure, index|
    formatted += failure.fully_formatted(index.next, colorizer)
  end
  formatted
end

#fully_formatted_pending_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒String

返回待定示例列表,以 RSpec 内置格式化程序的输出方式完全格式化。

返回值

  • (String)

    待定示例列表,以 RSpec 内置格式化程序的输出方式完全格式化。

122
123
124
125
126
127
128
129
130
131
132
# File 'lib/rspec/core/notifications.rb', line 122
def fully_formatted_pending_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
  return if RSpec.configuration.pending_failure_output == :skip
  formatted = "\nPending: (Failures listed here are expected and do not affect your suite's status)\n".dup
  pending_notifications.each_with_index do |notification, index|
    formatted << notification.fully_formatted(index.next, colorizer)
  end
  formatted
end

#notificationsArray<RSpec::Core::Notifications::ExampleNotification>

返回示例作为通知

返回值

91
92
93
# File 'lib/rspec/core/notifications.rb', line 91
def notifications
  @notifications ||= format_examples(examples)
end

#pending_examplesArray<RSpec::Core::Example>

返回待定示例列表。

返回值

85
86
87
# File 'lib/rspec/core/notifications.rb', line 85
def pending_examples
  @reporter.pending_examples
end

#pending_notificationsArray<RSpec::Core::Notifications::SkippedExampleNotification, RSpec::Core::Notifications::PendingExampleFailedAsExpectedNotification>

返回待定示例作为通知

104
105
106
# File 'lib/rspec/core/notifications.rb', line 104
def pending_notifications
  @pending_notifications ||= format_examples(pending_examples)
end