Run Rspec within vim and seeing result in your Firefox2

Thanks to cassiomarques, we can run rspec from within vim and see the results in FF.

You might be surprised though, when you run it and wait and wait, and nothing seems happening. Mostly likely it just that the running code raise an exception and no output to either FF or you vim. If you look at the terminal window where you started you vim, you will see the backtrace though. So why not display the backtrace in FF then, just like the image below?

A failure message window

A failure message window

Here is the part of the script modified from his original one:

rescue Exception => e"#{report_file}", "w") do |file|
    file.write("#{e.message} <br />")
    file.write e.backtrace.join("<br />")

Another thing worth to mention is that handling vim type of links doesn’t work with his approach in either FF3 and FF2. I had to install a plugin called Mozex. My experience is that it only works for FF2. Once you install it and restart your FF2, go to Add-Ons and click on “Preference” of this plugin. goto “Universal” tab. type “vim” into the first textbox and /path/to/open_vim to the second one just like the image shown below:

Mozex plugin setup

Mozex plugin setup

Speaking of open_vim, since Mozex pass the whole URL (vim://Users/blah/blah.rb?line_number) back, so the regex for parsing it should be changed to:


~ by Yi Wen on March 11, 2009.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: