My app has some logic that permits some actions before the user logs in,
and I depend upon session[:session_id] as a handle for some state.
My requests testing fails because session[:session_id] is null. I
attempted a somewhat brute force approach of putting this in my
specs/requests/authentication_spec.rb file:
require ‘spec_helper.rb’
class ApplicationController < ActionController::Base
def self.stub_session_id
session # force lazy load
session[:session_id] ||= “kaboodle”
end
end
…
but when I call stub_session_id, I get a warning and an error:
DEPRECATION WARNING: Disabling sessions for a single controller has been
deprecated. Sessions are now lazy loaded. So if you don’t access them,
consider them off. You can still modify the session cookie options with
request.session_options. (called from stub_session_id at
spec/requests/authentication_spec.rb:5)
and:
Failure/Error: session[:session_id] ||= "kanoodle"
TypeError:
can't convert Symbol into Integer
I’m sure this is obvious to those skilled in the dark arts of rspec and
rails, but I’ve not passed my initiation rites yet. Any clues on how I
can stub session[:session_id]?
TIA.