Authlogic and RSpec, errors only running all examples
I have a Profiles Controller that acts_as_authentic
with AuthLogic and I am trying to test this action:
class ProfilesController < ApplicationController
before_filter :require_user, :except => ['new', 'create']
def index
redirect_to(current_user)
end
end
The following example is in a spec file with 18 other pending examples. When autospec runs only this file I get an output like this 19 examples, 0 failures, 18 pending
which says the example is passing, when autospec runs all my specs I get 145 examples, 19 failures
all examples from this spec are failing now.
describe ProfilesController, "for logged in user" do
before(:each) do
@profile = Factory(:profile)
controller.stubs(:current_user).returns(@profile)
ApplicationController.stubs(:require_user).returns(true)
end
# Index
context "on get to index" do
it "should redirect to show user's profile" do
get :index
response.should redirect_to(profile_url(@profile))
end
end
end
I get this error for every failing spec when autospec runs all the specs:
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开发者_Go百科/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:
What would cause this problem only when all specs are run?
Perhaps in your before filter you could add some steps to log out the current session.
精彩评论