When installed as a gem and you're using Test::Unit, hydra makes it so you can't run an individual test file
fhwang opened this issue · 4 comments
I installed hydra as a gem, and was able to run a full rake task. But then if I try to run one individual test, like so:
ruby test/unit/blog_post_test.rb
... it just seems to load the environment and then exit without running any tests.
There is a workaround, which is just to simply install it as a plugin instead of a gem. For some reason that works fine--maybe there's some load-order thing going on?
I can run individual tests fine, so it's probably a load issue on your end.
The only place you should load hydra is in your Rakefile. Did you happen to mistakenly include it in your test_helper?
Hydra disables Test::Unit's auto-run so it can manage the test suite, so if you require it in your test helper it disables the run-at-exit that T::U uses to run the file.
I'm wondering if part of the issue is that I'm trying to package hydra with the Rails app. It probably wasn't clear earlier; when I said "I installed hydra as a gem", I meant by putting it in vendor/gems/ of my Rails app. Not sure if that's something other people are doing with hydra.
What I'm doing is: I have lib/tasks/hydra.rake, which defines the tasks. It also was necessary to do this:
$: << "vendor/plugins/hydra/lib"
require 'hydra'
require 'hydra/tasks'
This works fine for me so I'll go ahead and close this. Thanks for Hydra.
similarly, if you put 'gem "hydra"' in your Gemfile it will get required into your environment. You'll need to specify :require => false
yup, with bundler you should make a gem group to only load when it's testing time. http://gembundler.com/groups.html