github How To: Test (devise) with Rails 3 and RSpec にいくつかのリソースがあります。しかし、ハウツーは非常に高レベルであり、私のコンテキストでは機能させることができません。ログに記録されたユーザー (before_filter :authenticate_user!) を必要とするコントローラーをテストするために、これらすべての部分をまとめて接続または構成する適切な方法は何ですか???
今のところ、単一のコントローラーで rspec を実行しようとしています..
require File.dirname(__FILE__) + '/../spec_helper'
describe ArticlesController do
fixtures :all
render_views
before (:each) do
@user = Factory.create(:user)
sign_in @user
end
it "index action should render index template" do
get :index
response.should render_template(:index)
end
end
rspecを実行したときの出力は次のとおりです
Failures:
1) ArticlesController index action should render index template
Failure/Error: Unable to find matching line from backtrace
SQLite3::ConstraintException: articles.user_id may not be NULL