简体   繁体   English

如何使用Rails run Spec扩展名运行调试器?

[英]How do I run debugger with the Rails run Spec extension?

I am using VsCode to write and edit some rspec tests. 我正在使用VsCode编写和编辑一些rspec测试。

What I would like to be able to do is run a specific 'it' or 'describe' block in debug mode. 我想做的是在调试模式下运行特定的“ it”或“ describe”块。

At this time I can run the rspec/spec file in debug mode but it executes all of the tests. 目前,我可以在调试模式下运行rspec / spec文件,但它将执行所有测试。

I have install 'Rails run Spec' extension which allows me to execute a specific 'it' or 'describe' block without the ability to debug. 我安装了“ Rails run Spec”扩展名,该扩展名使我可以执行特定的“ it”或“ describe”块而无须调试。

Ideally I would like both options married together. 理想情况下,我希望两个选择都结婚。

I have done some digging but not able to find anything that fits my scenario. 我做了一些挖掘,但是找不到适合我的情况的任何东西。

Any help would be greatly appreciated. 任何帮助将不胜感激。

Joe

Add pry-byebug to your gemfile and run bundle install pry-byebug添加到您的gemfile并运行bundle install

# Gemfile
gem 'pry-byebug'

Then, whenever you want to inspect a test, add binding.pry inside the test. 然后,每当您要检查测试时,请在测试内部添加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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM