Tuesday, April 04, 2006

Execute Ruby Tests in IntelliJ

IntelliJ is a great IDE. Unfortunatley, the support for Ruby is lacking. However, using the External Tools you can set up IntelliJ to run your Ruby TestUnit tests. (Jeremy Stell-Smith had the original idea, Obie Fernandez and I tweaked it a bit to get the following directions.)
  1. Open the settings dialog. (Ctrl + Alt + S)
  2. Click External Tools. (P)
  3. Add. (Alt + A)
  4. Set the name to whatever you want.
  5. put "ruby" in the Program text box.
  6. put "$FileDirRelativeToProjectRoot$\$FileName$" in the Parameters text box.
  7. put "$ProjectFileDir$" in the Working directory text box.
  8. click OK.
That's it. Your external program should now be listed in the context menu when you right click in the editing area of any ruby file.

NOTE: If you put a breakpoint in a ruby file and execute that file the breakpoint will be hit and you will drop into irb in the Run window of IntelliJ.

Additional suggestions.
  • Create a Keymap for quickly running the tests without the need for a context menu.
  • Create an external program that checks valid Ruby syntax. This can be done by adding an additional external program and setting the Program to "ruby", Parameters to "-c $FileName$", and the Working directory to "$FileDir$"

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.