ApplicationController:Rails + rspec + devise = metodo non definito `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
Risultato:
Failure/Error: get 'index'
NoMethodError:
undefined method `authenticate_user!' for #<DashboardsController:0x007fef81f2efb8>
Rotaie Versione: 3.1.3
versione Rspec: versione 2.8.0
Devise: 1.5.3
Nota: Ho anche creato il supporto dei file/deviser.rb ma questo non aiuta. Qualche idea?
Il [devise Wiki] (https://github.com/plataformatec/devise/wiki/How-To:-Controllers-and-Views-tests-with-Rails-3- (and-rspec)) fornisce un alcuni modi diversi di integrare escogitare con rspec. –