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
感謝[@Shevaun](http://stackoverflow.com/users/156109/shevaun)爲錯字校正 – jefflunt