ngauthier/hydra

Hydra should allow setting up the Ruby load path

brynary opened this issue · 8 comments

When running Test::Unit tests, it is convention to have the test/ directory in the Ruby load path, and when running RSpec tests it's convention to have spec/ in the load path.

I think Hydra's TestTask should support a "libs" option that mirrors Ruby's TestTask "libs" and sets up the load path.

Sounds good.

I was also thinking about have a "preload" option where you can have it load your test/spec helper. Then in the helper you can modify your load path.

Also, we could just have hydra add the common load paths for test files by default (it already does this with cucumber).

I think it would be worth making Hydra behave like Test::Unit does in this respect (I actually tried that right off the bat).Unless this affect Hydra's interoperability with other testing frameworks?

For me, not having test/ loaded is the only niggle in an otherwise brilliant tool.

Yeah I was thinking about including test and spec in the load path. The only possible gotcha is that cucumber likes to include lots of stuff for you. Hopefully it won't get in the way.

+1 for this one. Setting it up as an option in the task or specifically including it would both help. Trying to get a workaround for including test/ in the load path myself -- any quick workaround to include it without branching?

@adam yeah just set your load path. Maybe you could put this in the rakefile:

$: << File.join(Rails.root, 'test') if Rails.env == 'test'

That is exactly how I've been getting around it. Not exactly pretty, but it does work.

There is also an undocumented feature:

https://github.com/ngauthier/hydra/blob/master/lib/hydra/worker.rb#L32

You could put:

$: << 'test'

into the file hydra_worker_init.rb, which is loaded when each worker boots up (so this will work remotely too).

Awesome, thanks! The hydra_worker_init.rb hack worked to get things running smoothly.