在调试模式下运行RSpec

Hak*_*ari 6 ruby rspec

这是一个简短的问题:我正在寻找一种在调试模式下使用-u交换机运行规范的方法,这样RSpec会失败掉到控制台,而不必debugger在代码中添加一行.有什么指针吗?

Hak*_*ari 10

会回答我自己的问题.

本教程之后,我创建了一个自定义格式化程序,如:

require "spec/runner/formatter/specdoc_formatter"

class DebuggerFormatter < Spec::Runner::Formatter::SpecdocFormatter
  def example_failed(example, counter, failure)
    super
    debugger if Kernel.respond_to?(:debugger)
  end
end
Run Code Online (Sandbox Code Playgroud)