Created
May 31, 2011 07:29
-
-
Save ozgun/1000107 to your computer and use it in GitHub Desktop.
sinatra-testing-with-sessions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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