Let's run through some extensions to improve your workflow if you use Rspec, a testing tool for Ruby!
Itโs another one of those VSCode extensions post - I know. But trust me on this one.
If you havenโt heard about Visual Studio Code (VSCode), itโs a text editor by Microsoft. One of the reasons why it's my editor of choice is the ability to install extensions made by fellow developers.
You can actually spend a day just installing and configuring extensions to your liking. Not that I did that. ๐
These three extensions made Test Driven Development (TDD) with Rspec much better. I love the ease of use these offer without sacrificing anything. Writing tests became faster and easier for me to do, I hope these help you out too! Hey that rhymed.
-
No need to look through your files in the sidebar, or use the search bar to open the spec file. You can jump between code and spec files with one command:
Ctrl + Shift + Y
(Cmd
for Mac)If the code file does not exist yet, this creates one for you! Works both ways.
Use case: I often do this at the start of the test writing process. I create the code file first, then press
Cmd + Shift + Y
to create the spec file. -
Rails Run Specs by Peter Negrei
I used to get the path of a
file/inside/lots/of/folders/sad_spec.rb
just to type out the test command:bundle exec rspec file/inside/lots/of/folders/sad_spec.rb
.This extension runs a spec file for you with in one swift command:
Ctrl + Shift + T
(Cmd
for Mac) It works even if you are in the code file as well, which is a pretty nifty feature.Use case: Probably my most used extension as I use it to run all the tests in one file. Gotta make sure they all pass. ๐ฏ
-
Ruby Test Explorer by Connor Shea
If you're a more visually oriented person, this is the extension youโre looking for. It helps you visualize all the tests in one file, with groupings according to files inside a describe or context block.
You get to see which blocks passed and which failed in an instant, and re-run any of those on their own.
Use case: Great for debugging that one single failing test that you have absolutely no idea why itโs failing when all other 10 tests passed. You can just select that single test (or block of tests) and debug.
This is just a small list, but the impact they have is unmatched.
Do you use any other VSCode Rspec extensions? Iโd love to know about them, letโs help each other out!
Top comments (7)
Great post, Jaye! I wish there was something like this in Sublime Text though...
Thank you! Sublime Text needs to step up their game ๐ค
Nice post! Haven't used Ruby/Rspec but it's in my bucket list. Will definitely use some of these. Keep writing ๐
Thanks Vaibhav! Yes, do pick it up sometime, itโs great ๐ฏ
Very useful, thanks! The second one is kinda life changing actually! ๐
Glad to help out! The second one is definitely the best ๐ฅ
vscode-run-rspec-file give us a lot of shortcuts to run our rspec tests