如何使用 Rails 运行 规范扩展 运行 调试器?

How do I run debugger with the Rails run Spec extension?

我正在使用 VsCode 编写和编辑一些 rspec 测试。

我希望能够在调试模式下运行一个特定的'it'或'describe'块。

此时我可以在调试模式下 运行 rspec/spec 文件,但它会执行所有测试。

我安装了 'Rails run Spec' 扩展程序,它允许我执行特定的 'it' 或 'describe' 块,但无法调试。

理想情况下,我希望这两种选择结合在一起。

我已经进行了一些挖掘,但无法找到适合我的情况的任何内容。

如有任何帮助,我们将不胜感激。

pry-byebug 添加到您的 gemfile 和 运行 bundle install

# Gemfile
gem 'pry-byebug'

然后,每当你想检查测试时,在测试中添加 binding.pry

# some_spec.rb

it "is not behaving how I want it to" do
  binding.pry
  expect(my_var).to eq(some_val)
end