Vladimir Sarić wrote this on October 5, 2011

Streamlining vim with RSpec and Cucumber

Few months back I was looking at ways to better our BDD workflow.

I stumbled upon this gist by @heisters and it got my attention right away. Basically, what it does is it lets you run your specs/scenarios directly from vim. It supports running the whole file or just the spec/scenario under your cursor. Of course the cursor doesn’t have to be directly on your spec’s description/context/it method calls, just within their body. The same goes for scenarios, no need to point your cursor over the scenario title, it’s enough for the cursor to be within it’s body.

I forked it to do some customization. I removed support for script files(script/spec and script/cucumber) and added Spork support.

Currently pressing Space-; will run the spec/scenario under your cursor and pressing Space-' will run the whole spec/feature file.

The nice part is that, if you are using Spork in your application and the Spork server is running, it will run the specs/scenarios through it, if not, it will just run without it, without any extra work on your part.

Installation is really simple, just put the file (don’t forget the .vim extension) in your vim’s plugin directory.

And remember you can always modify the keybinds to your liking. RunTest function will run a specific spec/scenario and the RunTestFile function will run the whole spec/feature file.

Feel free to comment and share your tips and tricks.

comments powered by Disqus

Suggested Reads

Rails Testing Handbook

A new ebook on building test-driven Rails apps with RSpec and Cucumber.

At Rendered Text, we have a long history with Ruby on Rails. Checking the blog archive reminds me that we published first posts about working with Rails way back in 2009.


Rendered Text is a software company. For questions regarding Semaphore, please visit semaphoreci.com. Otherwise, feel free to get in touch any time by sending us an email.