私はRailsにかなり慣れていません。RSpecでアプリを開発しています。Facebooker2のチュートリアルに従い、before_filter
認証用に を追加しました。
#app/controller/application_controller.rb
before_filter :ensure_authenticated
ただし、理解できる有効なセッションがないため、以下のような私の仕様は失敗しました。
#spec/controllers/answers_controller_spec.rb
describe "GET index" do
it "assigns all answers as @answers" do
get :index, {}, valid_session
assigns(:answers).should include(answers(:reading))
end
end
しかし、次の関数で rspec が使用する有効なセッションを偽造する方法を見つけることができないようです。
#spec/controllers/answers_controller_spec.rb
def valid_session
{}
end
まったく方法はありますか?そうでない場合、そのような場合のレールのやり方は何ですか?