1

我想在 rspec 测试期间在方法中启动调试器。我知道,我可以在规范中做到这一点(就像在这个问题中一样),我--debug在我的.rspec文件中。

我想debugger输入一个正在测试的方法:

it "should be OK" do
    User.ok? should be_true
end

class User
    def ok?
        do_something
        debugger      #here is my breakpoint
        do_something
    end
end

当我执行与该示例类似的操作并运行 rspec (使用rake specorguardrspec)时,断点不起作用。

4

1 回答 1

3

您应该将调试器 gem 放在 gemfile 中的 :test 组下。

gem 'debugger', group: [:development, :test]
于 2012-05-10T08:33:29.520 回答