Running Hydra against specs don't load gems required in config/environments/test.rb
joshuaclayton opened this issue · 5 comments
Even though factory_girl is configured within the test environment, individual specs don't seem to be loading what's required.
Here's the relevant files and output: https://gist.github.com/7e8577ebc18ab217d666
Hydra will run in the environment that you boot. Please try again with
RAILS_ENV=test rake hydra
and let me know if the issue still stands.
Ah cool! Any way to get hydra to respect ENV["RAILS_ENV"] ||= 'test'
?
well, test helper is not actually loaded until the test file itself is run, so I am not sure.
I always manually set the rails env myself because I don't trust rails to always get it right.
You could add ENV["RAILS_ENV"] ||= 'test' to the inside of the rake task.
You could also use a rake task to set the environment. If you have:
namespace :env do
desc "Use Test environment"
task :test do
RAILS_ENV = 'test'
end
end
Then you can run:
rake env:test hydra
OR add env:test as a prereq:
Hydra::TestTask.new('hydra:test' => 'env:test') do |t|
...
Wow I didn't know you could do this:
Hydra::TestTask.new('hydra:test' => 'env:test') do |t|
that's awesome :-)