My _spec
file includes the code below, but my test fails with:
NameError in 'MembershipsController should allow you to save updates to the notes'
undefined local variable or method `activate_authlogic' for #<Spec::Rails::Example::ControllerExampleGroup::Subclass_1:0x107cee930>
I don't understand why activate_authlogic
is undefined in this case. I've us开发者_C百科ed this line in TestUnit many times, and the RSpec examples I've read all seem to say that this should work. NOTE: I've also tried adding require 'authlogic'
to the top of the _spec
file, but it produces an identical error message.
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'ruby-debug'
describe MembershipsController do
before(:each) do
activate_authlogic
@admin = Factory(:admin, :email => "admin@example.com")
UserSession.create(@admin)
end
...
end
Apparently a misunderstanding on my part. Instead of require 'authlogic'
I needed require 'authlogic/test_case'
精彩评论