Skip to content

Instantly share code, notes, and snippets.

@loz
Created June 16, 2012 08:24
Show Gist options
  • Save loz/2940508 to your computer and use it in GitHub Desktop.
Save loz/2940508 to your computer and use it in GitHub Desktop.
Setting Session in Sinatra/Rspec
#Took me ages to work this out:
def setup_session(session = {})
Rack::Session::Abstract::SessionHash.stub(:new).and_return(session)
end
#then in your tests
before :each do
setup_session :user_id => User.first.id
get '/user_required'
end
it "works!" do
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment