Fixing test infrastructure
stffn opened this issue · 5 comments
stffn commented
For Rails 2.x, testing works quite nicely: either call
$ rake
or specify the Rails version from gems to test against:
$ RAILS_VERSION=2.3.11 rake
However, with Rails 3, this gets a bit messy. I currently need to set up a dummy project (say, test-app) and execute the tests from inside a bundle exec, thus:
$ cd test-app
$ bundle exec bash
$ cd path-to-decl-auth
$ RAILS_ROOT=path-to-test-app rake
We really need to fix this...
dgm commented
I guess part of the problem is, what version of rails should this test against? Should we have a Gemfile present?
dgm commented
Against 3.2.3, I get:
cannot load such file -- initializer (LoadError)
dgm commented
Suggestion: (Sorry for so many posts, I'm rambling as ideas come to me)
Use Bundler to specify several different groups, for different versions of rails...
dgm commented
This make the tests run for me in rails 3.2.3:
diff --git a/test/test_helper.rb b/test/test_helper.rb
index f9078ef..1b99ba7 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -23,7 +23,7 @@ unless defined?(ActiveRecord)
end
unless defined?(Rails) # needs to be explicit in Rails < 3
- %w(action_pack action_controller active_record active_support initializer).each {|f| require f}
+ %w(action_pack action_controller/railtie active_record active_model rails/test_unit/railtie).each {|f| require f}
end
end
@@ -118,6 +118,14 @@ if Rails.version < "3"
map.connect ':controller/:action/:id'
end
else
+ module RbConfig
+ class Application < ::Rails::Application
+ # configuration here if needed
+ config.active_support.deprecation = :stderr
+ end
+ end
+
+ RbConfig::Application.initialize!
#Rails::Application.routes.draw do
Rails.application.routes.draw do
match '/name/spaced_things(/:action)' => 'name/spaced_things'
I don't know yet what that does to other version of rails.