VSCode Extensions for Faster Testing with Rspec 🛠
Tags: ruby, rails, vscode, testing
Published: 2020-05-24 03:04:21

Let's run through some extensions to improve your workflow if you use [**Rspec**](https://rspec.info/), 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](https://code.visualstudio.com/) (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](https://marketplace.visualstudio.com/) 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](https://marketplace.visualstudio.com/items?itemName=sporto.rails-go-to-spec) by [sporto](https://marketplace.visualstudio.com/publishers/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](https://marketplace.visualstudio.com/items?itemName=noku.rails-run-spec-vscode) by [Peter Negrei](https://marketplace.visualstudio.com/publishers/noku)

    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](https://marketplace.visualstudio.com/items?itemName=connorshea.vscode-ruby-test-adapter) by [Connor Shea](https://marketplace.visualstudio.com/publishers/connorshea)

    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](https://dev-to-uploads.s3.amazonaws.com/i/4y7ozx4yqywd9zk5yihp.png)
    _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!