Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sinatra-testing-with-sessions
# Middleware: my_app.rb
class MyApp < Sinatra::Base
enable :sessions
get '/testing' do
puts env['rack.session'].inspect
'testing'
end
end
----------------------------------------------------
# Test for MyApp: my_app_spec.rb
require 'spec_helper'
require 'rack/test'
describe MyApp do
include Rack::Test::Methods
def app
MyApp
end
it "testing" do
get '/testing', {}, {'rack.session' => {'user_id' => 2}}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment