Skip to content

Instantly share code, notes, and snippets.

@jasonngpt
Created November 27, 2013 03:34
Show Gist options
  • Save jasonngpt/7670304 to your computer and use it in GitHub Desktop.
Save jasonngpt/7670304 to your computer and use it in GitHub Desktop.
Sinatra RSpec Session Variables
# my_test.rb (first line, or at least before you require your 'my_app.rb')
ENV['RACK_ENV'] = 'test'
# my_app.rb (your sinatra application)
enable :sessions unless test?
# my_test.rb (in your test block)
session = {} OR session = { "username" => "test" }
get '/', {}, 'rack.session' => session
assert_equal 'value', session[:key]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment