2011-09-06 145 views
2

_spec文件包括下面的代码,但我的测试失败:RSpec的:未定义的局部变量或方法`activate_authlogic”

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> 

我不明白为什么activate_authlogic在这种情况下是不明确的。我在TestUnit中多次使用过这一行,并且我读过的RSpec示例似乎都说这应该起作用。 注意:我也尝试将require 'authlogic'添加到_spec文件的顶部,但它会产生相同的错误消息。

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') 
require 'ruby-debug' 

describe MembershipsController do 

    before(:each) do 
    activate_authlogic 
    @admin = Factory(:admin, :email => "[email protected]") 
    UserSession.create(@admin) 
    end 

    ... 

end 

回答

2

显然是我的错误理解。代替require 'authlogic'

我需要require 'authlogic/test_case'

+0

感谢[@Shevaun](http://stackoverflow.com/users/156109/shevaun)为错字校正 – jefflunt

相关问题