类: RSpec::Core::Notifications::FailedExampleNotification

继承
ExampleNotification 显示全部
定义于
lib/rspec/core/notifications.rb

概述

FailedExampleNotification 扩展了 ExampleNotification,其中包含对失败或挂起的规范有用的信息。

示例

def example_failed(notification)
  puts "Hey I failed :("
  puts "Here's my stack trace"
  puts notification.exception.backtrace.join("\n")
end

另请参阅

实例属性摘要 折叠

实例方法摘要 折叠

实例属性详细信息

#exampleRSpec::Core::Example

当前示例

返回

156
157
158
# File 'lib/rspec/core/notifications.rb', line 156
def example
  @example
end

实例方法详细信息

#colorized_formatted_backtrace(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒Array<String>

返回失败的彩色格式化的回溯。

参数

  • colorizer (#wrap) (默认值: ::RSpec::Core::Formatters::ConsoleCodes)

    用来对 message_lines 进行着色的对象

返回

  • (Array<String>)

    示例的彩色回溯行

195
196
197
# File 'lib/rspec/core/notifications.rb', line 195
def colorized_formatted_backtrace(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
  @exception_presenter.colorized_formatted_backtrace(colorizer)
end

#colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒Array<String>

返回此失败的彩色行消息。

参数

  • colorizer (#wrap) (默认值: ::RSpec::Core::Formatters::ConsoleCodes)

    用来对 message_lines 进行着色的对象

返回

  • (Array<String>)

    示例失败消息,已着色

180
181
182
# File 'lib/rspec/core/notifications.rb', line 180
def colorized_message_lines(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
  @exception_presenter.colorized_message_lines(colorizer)
end

#descriptionString

返回示例描述。

返回

  • (String)

    示例描述

165
166
167
# File 'lib/rspec/core/notifications.rb', line 165
def description
  @exception_presenter.description
end

#exceptionException

返回示例失败。

返回

  • (Exception)

    示例失败

160
161
162
# File 'lib/rspec/core/notifications.rb', line 160
def exception
  @exception_presenter.exception
end

#formatted_backtraceArray<String>

返回失败的格式化的回溯。

返回

  • (Array<String>)

    示例的回溯行

187
188
189
# File 'lib/rspec/core/notifications.rb', line 187
def formatted_backtrace
  @exception_presenter.formatted_backtrace
end

#fully_formatted(failure_number, colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒String

返回以 RSpec 内置格式化程序发出的方式完全格式化失败信息。

返回

  • (String)

    以 RSpec 内置格式化程序发出的方式完全格式化失败信息。

201
202
203
# File 'lib/rspec/core/notifications.rb', line 201
def fully_formatted(failure_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes)
  @exception_presenter.fully_formatted(failure_number, colorizer)
end

#fully_formatted_lines(failure_number, colorizer = ::RSpec::Core::Formatters::ConsoleCodes) ⇒Array<string>

返回以 RSpec 内置格式化程序发出的方式完全格式化失败信息,按行拆分。

返回

  • (Array<string>)

    以 RSpec 内置格式化程序发出的方式完全格式化失败信息,按行拆分。

207
208
209
# File 'lib/rspec/core/notifications.rb', line 207
def fully_formatted_lines(failure_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes)
  @exception_presenter.fully_formatted_lines(failure_number, colorizer)
end

#message_linesArray<String>

返回此失败的逐行消息。

返回

  • (Array<String>)

    示例失败消息

172
173
174
# File 'lib/rspec/core/notifications.rb', line 172
def message_lines
  @exception_presenter.message_lines
end