我是一名对RSpec测试有些陌生的人,正在尝试使用RSpec 2和Authlogic 3身份验证在我的Rails 3应用程序中运行一些控制器测试。
按照Authlogic文档提供的步骤(http://rdoc.info/github/binarylogic/authlogic/master/Authlogic/TestCase),我在我的文件中得到了以下代码:
spec_helper.rb
require "authlogic/test_case" # include at the top of test_helper.rb
events_controller_spec.rb
require 'spec_helper'
setup :activate_authlogic
通过运行rake spec SPEC='spec/controllers/eventos_controller_spec.rb'
进行测试时,我得到了以下错误:
events_controller_spec.rb:2: undefined method `setup' for main:Object (NoMethodError)
在使用authlogic之前,我运行测试时没有遇到任何问题。
我正在使用Ubuntu 11.04和以下配置:
ruby - 1.8.7
rails - 3.0.7
authlogic - 3.0.2
rspec-rails - 2.4.1
factory_girl_rails - 1.0.1