2011-09-06 104 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

相關問題