ApplicationController:Rails + rspec + devise = undefined method `authenticate_user! '
class ApplicationController < ActionController::Base
before_filter :authenticate_user!
protect_from_forgery
end
DashboardsController:
class DashboardsController < ApplicationController
def index
end
end
DashboardsControllerSpec:
require 'spec_helper'
describe DashboardsController do
include Devise::TestHelpers
describe "GET 'index'" do
it "returns http success" do
get 'index'
response.should be_success
end
end
end
Результат:
Failure/Error: get 'index'
NoMethodError:
undefined method `authenticate_user!' for #<DashboardsController:0x007fef81f2efb8>
Рельсы версия: 3.1.3
Rspec версия: версия 2.8.0
Разрабатывают: 1.5.3
Примечание: Я также создал поддержки/файл deviser.rb, но это не помогает. Есть идеи?
[devize Wiki] (https://github.com/plataformatec/devise/wiki/How-To:-Controllers-and-Views-tests-with-Rails-3- (and-rspec)) предоставляет несколько различных способов интеграции разработки с rspec. –