RSpec set session object

This is explained in the Guide to Testing Rails Applications in section 4 “Functional Tests for your Controllers. The get action takes a params hash and a session hash, e.g.:

get(:show, {'id' => "12"}, {'user_id' => 5})

You should be able to pass in nil for the params hash in your example, then pass in your desired session parameters:

get :index, nil, {coupon: 'abcd'}

I recommend a thorough reading of the Rails guide for anyone using RSpec for Rails testing. rspec-rails leverages the existing Rails test classes, a point which is not made very clear in the rspec-rails docs.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)