Authlogic и RSpec, ошибки только при запуске всех примеров

У меня есть контроллер профилей, который acts_as_authentic с AuthLogic, и я пытаюсь проверить это действие:

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

  def index
    redirect_to(current_user)
  end
end

Следующий пример находится в файле спецификаций с 18 другими ожидающими примерами. Когда autospec запускает только этот файл, я получаю вывод, подобный этому 19 examples, 0 failures, 18 pending, в котором говорится, что пример проходит, когда autospec запускает все мои спецификации, я получаю 145 examples, 19 failures все примеры из этой спецификации теперь терпят неудачу.

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

Я получаю эту ошибку для каждой неудачной спецификации, когда 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: "[email protected]", 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:

Что может вызвать эту проблему только при запуске всех спецификаций?


person trobrock    schedule 04.07.2010    source источник
comment
кажется, что некоторое использование mock_model(ProfileSession) в другом файле спецификации, который был запущен до этого, вызывало проблемы   -  person trobrock    schedule 05.07.2010
comment
Можете показать код с вашего :profile завода?   -  person zetetic    schedule 06.07.2010


Ответы (1)


Возможно, в вашем фильтре «до» вы могли бы добавить несколько шагов для выхода из текущего сеанса.

person jasonpgignac    schedule 11.07.2010