hydra icon indicating copy to clipboard operation
hydra copied to clipboard

Hydra should allow setting up the Ruby load path

Open brynary opened this issue 14 years ago • 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.

brynary avatar Aug 22 '10 10:08 brynary

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).

ngauthier avatar Aug 22 '10 15:08 ngauthier

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.

rodreegez avatar Nov 23 '10 17:11 rodreegez

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.

ngauthier avatar Nov 23 '10 17:11 ngauthier

+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?

adamfortuna avatar Dec 03 '10 15:12 adamfortuna

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

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

ngauthier avatar Dec 03 '10 15:12 ngauthier

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

rodreegez avatar Dec 03 '10 16:12 rodreegez

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).

ngauthier avatar Dec 03 '10 16:12 ngauthier

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

adamfortuna avatar Dec 03 '10 16:12 adamfortuna