I\'m trying to set a session object from my controller spec.
it \'use invalid coupon\' do
session[:coupon] = \'abcd\'
Service.any_instance.stub(:va
In Rails 5+, if you are using ActionController::TestCase session is passed as a keyword arg.
Setting params and session would look like:
get(:show, params: {'id' => "12"}, session: {'user_id' => 5})
Setting only the session would look like,
get(:show, session: {'user_id' => 5})
If you are using ActionDispatch::IntegrationTest, which is the new default for for controller tests, you are not able to set the session variables and should set them by walking your test through the login flow.