[RSpec] Various ways to use Devise in test code

Tadashi Shigeoka ·  Thu, December 13, 2012

Notes on various ways to use Devise when writing test code with Ruby on Rails + RSpec.

Mainly read this:

How To: Controllers and Views tests with Rails 3 (and rspec) · plataformatec/devise Wiki

■ Using stubs for current_user

Controller tests

before do
  controller.stub!(:current_user).and_return(FactoryGirl.create(:user))
end

Also:

deviseを使ったコントローラのテスト #Rails #Ruby #devise #Rspec - Qiita

That’s all from the Gemba.