From 35929838f7d661a00f495a1ccfdc1bb45939d868 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 4 Aug 2011 14:17:09 -0400 Subject: [PATCH] ensure correct environment --- lib/guard/hydra.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/guard/hydra.rb b/lib/guard/hydra.rb index 18190a1..5e3b1d4 100644 --- a/lib/guard/hydra.rb +++ b/lib/guard/hydra.rb @@ -17,13 +17,22 @@ class Guard::Hydra < Guard::Guard :show_runner_log => true, :hydra_config => 'config/hydra.yml', :test_matchers => [ :rspec ], - :all_on_start => false + :all_on_start => false, + :env => 'test' }.merge(@options) end def start super Guard::UI.info "Guard::Hydra is waiting to run tests..." + + begin + ENV['RAILS_ENV'] = @options[:env] + require rails_application + rescue LoadError + Guard::UI.info "Not a Rails app, using default environment settings" + end + run_all if @options[:all_on_start] end @@ -47,7 +56,7 @@ class Guard::Hydra < Guard::Guard hydra = Hydra::Master.new( :listeners => [ Hydra::Listener::ProgressBar.new ], :files => files.uniq, - :environment => 'test', + :environment => @options[:env], :config => @options[:hydra_config] )