Я обновляюсь до rails 3 и rspec 2.
В моем spec_helper выдается ошибка "undefined method` mock_model '".Мой метод current_user устанавливает фиктивного пользователя для authlogic и генерирует эту ошибку.
Мой помощник спецификаций выглядит так
require 'authlogic/test_case'
require 'shoulda'
require 'helpers'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
Dir[Rails.root.join("spec/factories/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
end
module LoginHelper
include Authlogic::TestCase
def login_user person
activate_authlogic
UserSession.create(...)
end
end
include LoginHelper
def current_user(stubs = {})
@current_user ||= mock_model("User", stubs)
end
def user_session(stubs = {}, user_stubs = {})
@current_user ||= mock_model(UserSession, {:user => current_user(user_stubs)}.merge(stubs))
end
def login(session_stubs = {}, user_stubs = {})
UserSession.stub!(:find).and_return(user_session(session_stubs, user_stubs))
end
def logout
@user_session = nil
end