Check if a user is signed out in devise

authentication, devise, rspec, ruby, ruby-on-rails

Solution

I think it's really what you need How To: Test controllers with Rails 3 and 4 (and RSpec)

Just check `current_user`. It should be `nil`

Add. Good practice is using syntax like this

-> { sign_out @admin }.should change { current_user }.from(@admin).to(nil)

Problem

I'm trying to check if an administrator is signed out in an Rspec test. However the usual signed_in? method can't be seen from rspec and isn't part of the RSpec Devise Helpers. Something like this is what i have in place ``` before (:each) do @admin = FactoryGirl.create(:administrator) sign_in @admin end it "should allow the admin to sign out" do sign_out @admin #@admin.should be_nil #@admin.signed_in?.should be_false administrator_signed_in?.should be_false end ``` Is there anothe way to check the session of the administrator and see if he's actually signed in or not?

Original source