DEV Community

Cover image for VSCode Extensions for Faster Testing with Rspec ๐Ÿ› 
Jaye Hernandez
Jaye Hernandez

Posted on

VSCode Extensions for Faster Testing with Rspec ๐Ÿ› 

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.

  1. Rails Go To Spec by sporto

    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.

  2. 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. ๐Ÿ’ฏ

  3. 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.

    Ruby Test Explorer Screenshot
    Image from Connor Shea

    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)

Collapse
 
raphael_jambalos profile image
Raphael Jambalos

Great post, Jaye! I wish there was something like this in Sublime Text though...

Collapse
 
jayehernandez profile image
Jaye Hernandez

Thank you! Sublime Text needs to step up their game ๐Ÿค”

Collapse
 
vaibhavkhulbe profile image
Vaibhav Khulbe

Nice post! Haven't used Ruby/Rspec but it's in my bucket list. Will definitely use some of these. Keep writing ๐Ÿ˜

Collapse
 
jayehernandez profile image
Jaye Hernandez

Thanks Vaibhav! Yes, do pick it up sometime, itโ€™s great ๐Ÿ’ฏ

Collapse
 
camblan profile image
Julien Camblan

Very useful, thanks! The second one is kinda life changing actually! ๐Ÿ™

Collapse
 
jayehernandez profile image
Jaye Hernandez

Glad to help out! The second one is definitely the best ๐Ÿ”ฅ

Collapse
 
thadeu profile image
Thadeu Esteves Jr

vscode-run-rspec-file give us a lot of shortcuts to run our rspec tests