A
A
A_Modestov2016-06-04 11:50:16
Ruby on Rails
A_Modestov, 2016-06-04 11:50:16

How to create session in rspec test?

Good afternoon, ladies and gentlemen. The question is, in one of the controller methods I receive data from the session created earlier:

def create
    provider = session['devise.oauth_data']['provider']
    uid = session['devise.oauth_data']['uid']
    .  .  .
end

How to reproduce this session in rspec controller test? This option doesn't seem to work:
describe 'POST #create' do
    before do
      session["devise.oauth_data"] = {provider: 'twitter', uid: '123456'}
    end
.  .  .
end

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jarosluv, 2016-06-08
@jarosluv

Try instead of `session["devise.oauth_data"]` to write `@request.session["devise.oauth_data"]` (or `request.session["devise.oauth_data"]`). Or you can try to lock the session object.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question