How can I run Ruby specs and / or tests in MacVim without blocking MacVim?

About 6 months ago, I switched from TextMate to MacVim for all of my developments, which mainly consist of coding in Ruby, Ruby on Rails, and JavaScript.

Using TextMate, when I needed to run a specification or test, I could just use the + R command in a test or specified file, and another window will open, and the results will be displayed using a β€œnice” format. If the specification or test was long, I could continue to work with the code base, since the test / specification was carried out in a separate process / window. After running the test, I could directly view the results in the corresponding line in the spec file.

The great rails.vim plugin from Tim Pope is very close to emulating this behavior in a MacVim environment. Run: Rake when the current buffer is a test or spec runs a file, then splits the buffer to display the results. You can navigate through the results and go to the appropriate place in the file.

The problem with the rails.vim method is that it blocks the MacVim window during the test. This can be a problem with large applications, which can have many settings / breaks built into the tests. In addition, the visual red / green html results displayed by TextMate (via --format pretty, I guess) are a little easier to scan than a split window.

This guy came about 18 months ago: http://cassiomarques.wordpress.com/2009/01/09/running-rspec-files-from-vim-showing-the-results-in-firefox/ script he worked with a little hack but the tests still worked in MacVim and blocked the current window.

Any ideas on how to fully reproduce the TextMate behavior described above in MacVim?

Thanks!

+4
source share
2 answers

There is a plugin called vim-addon-background-cmd that allows you to run tasks in the background instead of blocking the vim interface. You will need to create a call to run through the background command. See the docs for more information on how to do this.

+1
source

A few months ago I was looking for the exact same thing. Then I discovered an autotest with rspec. Now I open a separate terminal window that shows my latest launch tests. If I change any relevant code files, my tests will automatically run for me (the files are viewed and if they change the test run).

If you want to have the same behavior like autotest in a project without rails, you can look at the watchr gem. This functionality is similar to autotest, but you can use it in ANY framework.

0
source

All Articles