Unittesting Ruby 1.9 in RubyMine 3.1.1

I like work with RubyMine 3.1.1 due to the easy way I can debug, browse through different files, checks etc. all the good stuff you only get with an IDE.
Further I really try to do TDD or at least write tests after implementing some new code – and hey isn’t there that nice feature within RubyMine that allows you to run all your tests? Yes there is but when you run it under Ruby 1.9.x you will get the IDE telling you that your tests failed (even though in the console window you can see all your tests have passed..). So why is that and how to fix?

The reason why this happens is because as of Ruby 1.9 test-unit is not anymore within the default package of rails. It made room for the more lightweight MiniTest. But that isn’t much of a worry download TestUnit via gem install (or click your way through RubyMine if you want..) and voilà all your unit tests will work as expected (or not depending on the status of your code..).

Coming this far on your own is not that much of a problem, mainly because the RubyMine tells you it is missing TestUnit. But how do you get the “Run all tests..” working again? In your local Gemfile (should be in the root directory of your project, you may have to create it on your own if your writing a Rails 3.0.x application) add the following line:

require 'test-unit'

Now you can run all your unit tests within RubyMine and get the nerve relieving green after all tests have run through successfully.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: