Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing test infrastructure #142

Open
stffn opened this issue Apr 29, 2012 · 5 comments
Open

Fixing test infrastructure #142

stffn opened this issue Apr 29, 2012 · 5 comments

Comments

@stffn
Copy link
Owner

stffn commented Apr 29, 2012

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
Copy link

dgm commented Apr 30, 2012

I guess part of the problem is, what version of rails should this test against? Should we have a Gemfile present?

@dgm
Copy link

dgm commented Apr 30, 2012

Against 3.2.3, I get:

cannot load such file -- initializer (LoadError) 

@dgm
Copy link

dgm commented Apr 30, 2012

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
Copy link

dgm commented Apr 30, 2012

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.

@stffn
Copy link
Owner Author

stffn commented Jun 12, 2012

See comment on #112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants