2

I would like to write some unit test with a logged user using Authlogic. To start right, I used some code hosted in http://github.com/binarylogic/authlogic_example. But I get an error after rake test, because of "test_helper.rb" and the following class:

class ActionController::TestCase
  setup :activate_authlogic
end

Here is my error:

NameError: undefined local variable or method `activate_authlogic' for

I think this Authlogic example is mapped over Rails 2; maybe it's a little bit different on Rails 3. Is there an other example where I can take example about unit test?

Many thanks.

Puru puru rin..
  • 501
  • 2
  • 5
  • 18

3 Answers3

15

Do you require 'authlogic/test_case' and include Authlogic::TestCase? I had a similar issue (using rspec, though) and read through the code at http://github.com/trevmex/authlogic_rails3_example

Martin Svalin
  • 2,227
  • 1
  • 17
  • 23
1

As of Rails 3.1 and Authlogic 3.0.3, the only thing I've had to add to activate authlogic was

features/support/env.rb

Before do
  activate_authlogic
end
Philippe Rathé
  • 8,888
  • 3
  • 22
  • 13
1

I don't realize where to put include Authlogic::TestCase, so I put this after the requires in spec_helper.rb and it worked. There is a better place for it?

Kadu Diógenes
  • 508
  • 1
  • 6
  • 19