【发布时间】:2012-01-11 12:34:50
【问题描述】:
应用控制器:
class ApplicationController < ActionController::Base
before_filter :authenticate_user!
protect_from_forgery
end
仪表板控制器:
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>
Rails 版本:3.1.3
Rspec 版本:2.8.0
设计版本:1.5.3
注意:我还创建了 support/deviser.rb 文件,但这无济于事。有什么想法吗?
【问题讨论】:
-
devise Wiki 提供了几种不同的方式将设计与 rspec 集成。
标签: ruby-on-rails rspec devise