rspec测试期间方法中的断点

时间:2023-01-18 11:19:34

I'd like to start debugger in methods during rspec test. I know, I can do it in the spec (like in this question), I have --debug in my .rspec file.

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

I'd like to put debugger in a methods that is under tests:

我想把调试器放在一个正在测试的方法中:

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

When I do something similar to that example and run rspec (using rake spec or guard or rspec) the breakpoind doesn't work.

当我做类似于该示例的操作并运行rspec(使用rake spec或guard或rspec)时,breakpoind不起作用。

1 个解决方案

#1


3  

You should put your debugger gem under the :test group in your gemfile.

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

gem 'debugger', group: [:development, :test]

#1


3  

You should put your debugger gem under the :test group in your gemfile.

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

gem 'debugger', group: [:development, :test]