As a lot more people start talking about Minitest, I want to give it a try. I was starting a new project today. It was a perfect chance to try out Minitest. I expected it to work perfectly out of the box with RubyMine, but apparently it is not.
I got this error when I tried running my test as usual.
`require': cannot load such file -- test_helper (LoadError)Basically, it says that Ruby can't find test_helper file that is required in the top of my Minitest test file. I knew that it's LOAD_PATH issue but I didn't actually know how to config it properly since I was spoiled by out of the box RSpec integration.
I did googling around by no luck. There's only a page show how to config Minitest report.
I did try to switch back to RSpec just to see whether it's still working fine, and it is. I looked at the runner command that's generated by RubyMine when we execute the spec. There's nothing special from what it generates for Minitest. It seems like RSpec does some work figuring out the path for us. That's why it works out of the box.
So I aim toward finding a way to manually config properly the test running path. Finally, I figured it out with the clue from this comment.
- First go to Run > Edit Configurations.
- On the left panel, select Defaults and Ruby
- Put the absolute path to your Rails project into Working directory: field
- Append field Ruby arguments with -Itest (tell Ruby to look into test directory)
- If you had run the test before, you need to remove all the configurations under Ruby section (outside Defaults) to force them to load the new configuration
- And enjoy the Minitest experiences! (Should work with TestUnit too)