Ruby on rails Authlogic和RSpec,仅运行所有示例时出错

Ruby on rails Authlogic和RSpec,仅运行所有示例时出错,ruby-on-rails,unit-testing,controller,rspec,authlogic,Ruby On Rails,Unit Testing,Controller,Rspec,Authlogic,我有一个Profiles控制器,它与AuthLogic的作用相同,我正在尝试测试这个动作: class ProfilesController < ApplicationController before_filter :require_user, :except => ['new', 'create'] def index redirect_to(current_user) end end 当autospec运行所有规范时,对于每个失败的规范,我都会遇到此错误

我有一个Profiles控制器,它与AuthLogic的作用相同,我正在尝试测试这个动作:

class ProfilesController < ApplicationController
  before_filter :require_user, :except => ['new', 'create']

  def index
    redirect_to(current_user)
  end
end
当autospec运行所有规范时,对于每个失败的规范,我都会遇到此错误:

19)
Spec::Mocks::MockExpectationError in 'ProfilesController for logged in user on get to index should redirect to show user's profile'
Mock "ProfileSession_1005" received unexpected message :priority_record= with (#<Profile id: nil, first_name: "Test", last_name: "User", email: "user133@example.com", username: "user133", crypted_password: "7aed8331f6d4518483855c07c1b5a507a3f81e5b52019d93d2e...", password_salt: "Nd2gQZjOUA0Ij0IuO6Vp", created_at: nil, updated_at: nil, is_admin: nil, persistence_token: "b439ff8bd952964a68a6d00126bafe954e4eab053d81872233e...", perishable_token: "xis77hpS32Wn9pu1PF5R", active: false>)
/Library/Ruby/Gems/1.8/gems/authlogic-2.1.5/lib/authlogic/session/persistence.rb:38:in `find'
/Library/Ruby/Gems/1.8/gems/authlogic-2.1.5/lib/authlogic/acts_as_authentic/session_maintenance.rb:96:in `get_session_information'
/Library/Ruby/Gems/1.8/gems/authlogic-2.1.5/lib/authlogic/acts_as_authentic/session_maintenance.rb:95:in `each'
/Library/Ruby/Gems/1.8/gems/authlogic-2.1.5/lib/authlogic/acts_as_authentic/session_maintenance.rb:95:in `get_session_information'
/Library/Ruby/Gems/1.8/gems/factory_girl-1.3.1/lib/factory_girl/proxy/create.rb:6:in `result'
/Library/Ruby/Gems/1.8/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:326:in `run'
/Library/Ruby/Gems/1.8/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:270:in `create'
/Library/Ruby/Gems/1.8/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:301:in `send'
/Library/Ruby/Gems/1.8/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:301:in `default_strategy'
/Library/Ruby/Gems/1.8/gems/factory_girl-1.3.1/lib/factory_girl.rb:20:in `Factory'
/Applications/MAMP/htdocs/my_application/spec/controllers/profiles_controller_spec.rb:5:
19)
Spec::Mocks::MockExpectationError在“获取索引时登录用户的ProfilesController应重定向以显示用户的配置文件”中出现错误
模拟“ProfileSession_1005”收到意外消息:priority_record=with(#)
/Library/Ruby/Gems/1.8/Gems/authlogic-2.1.5/lib/authlogic/session/persistence.rb:38:in'find'
/Library/Ruby/Gems/1.8/Gems/authlogic-2.1.5/lib/authlogic/acts\u as\u authentic/session\u maintenance.rb:96:“获取会话信息”
/Library/Ruby/Gems/1.8/Gems/authlogic-2.1.5/lib/authlogic/acts_as_authentic/session_maintenance.rb:95:in'each'
/Library/Ruby/Gems/1.8/Gems/authlogic-2.1.5/lib/authlogic/acts\u as\u authentic/session\u maintenance.rb:95:在“获取会话信息”中
/Library/Ruby/Gems/1.8/Gems/factory_girl-1.3.1/lib/factory_girl/proxy/create.rb:6:in'result'
/Library/Ruby/Gems/1.8/Gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:326:in'run'
/Library/Ruby/Gems/1.8/Gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:270:in'create'
/Library/Ruby/Gems/1.8/Gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:301:in'send'
/Library/Ruby/Gems/1.8/Gems/factory\u girl-1.3.1/lib/factory\u girl/factory.rb:301:在“默认”策略中
/Library/Ruby/Gems/1.8/Gems/factory_girl-1.3.1/lib/factory_girl.rb:20:in'factory'
/Applications/MAMP/htdocs/my_application/spec/controllers/profiles_controller_spec.rb:5:

只有在运行所有规范时,才会出现此问题的原因是什么?

也许在您的before筛选器中,您可以添加一些步骤以注销当前会话。

也许在before筛选器中,您可以添加一些步骤以注销当前会话。

似乎使用了
模拟模型(ProfileSession)
在此之前运行的另一个规范文件中导致了问题扫描您显示的代码来自
:profile
工厂?似乎在在此之前运行的另一个规范文件中使用了
模拟模型(ProfileSession)
导致了问题扫描您显示的代码来自
:profile
工厂?
19)
Spec::Mocks::MockExpectationError in 'ProfilesController for logged in user on get to index should redirect to show user's profile'
Mock "ProfileSession_1005" received unexpected message :priority_record= with (#<Profile id: nil, first_name: "Test", last_name: "User", email: "user133@example.com", username: "user133", crypted_password: "7aed8331f6d4518483855c07c1b5a507a3f81e5b52019d93d2e...", password_salt: "Nd2gQZjOUA0Ij0IuO6Vp", created_at: nil, updated_at: nil, is_admin: nil, persistence_token: "b439ff8bd952964a68a6d00126bafe954e4eab053d81872233e...", perishable_token: "xis77hpS32Wn9pu1PF5R", active: false>)
/Library/Ruby/Gems/1.8/gems/authlogic-2.1.5/lib/authlogic/session/persistence.rb:38:in `find'
/Library/Ruby/Gems/1.8/gems/authlogic-2.1.5/lib/authlogic/acts_as_authentic/session_maintenance.rb:96:in `get_session_information'
/Library/Ruby/Gems/1.8/gems/authlogic-2.1.5/lib/authlogic/acts_as_authentic/session_maintenance.rb:95:in `each'
/Library/Ruby/Gems/1.8/gems/authlogic-2.1.5/lib/authlogic/acts_as_authentic/session_maintenance.rb:95:in `get_session_information'
/Library/Ruby/Gems/1.8/gems/factory_girl-1.3.1/lib/factory_girl/proxy/create.rb:6:in `result'
/Library/Ruby/Gems/1.8/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:326:in `run'
/Library/Ruby/Gems/1.8/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:270:in `create'
/Library/Ruby/Gems/1.8/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:301:in `send'
/Library/Ruby/Gems/1.8/gems/factory_girl-1.3.1/lib/factory_girl/factory.rb:301:in `default_strategy'
/Library/Ruby/Gems/1.8/gems/factory_girl-1.3.1/lib/factory_girl.rb:20:in `Factory'
/Applications/MAMP/htdocs/my_application/spec/controllers/profiles_controller_spec.rb:5: