Skip to content

Instantly share code, notes, and snippets.

@ozgun
Created May 31, 2011 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozgun/1000107 to your computer and use it in GitHub Desktop.
Save ozgun/1000107 to your computer and use it in GitHub Desktop.
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