I am having some troubles with one rspec test. I am writing simple logging-in system. Everything works fine, except for the logging-out test:
context 'when user is logged in' do
before(:each) do
session[:user_id] = User.first.id;
end
it 'allows user to log out' do
delete :destroy
session.should be_empty
end
end
Destroy action:
def destroy
reset_session
redirect_to new_session_path
end
I have checked that during the test session is cleared right after reset_session
command, however it is not cleared in rspec after delete :destroy
. I am wondering how those two sessions are correlated.
I have also tried session.delete(:user_id)
with exactly same result. It seems that rspec detects adding keys to session without any problems, but cannot see sth was removed. Ideas?