Permalink
Browse files

added helper for session

  • Loading branch information...
1 parent 7651d48 commit 1cdb894fd7890a1c7b9945aecda0a682bad9af2a @rkh committed Apr 21, 2010
Showing with 17 additions and 0 deletions.
  1. +17 −0 lib/sinatra/test_helper.rb
@@ -44,6 +44,23 @@ def app(*options, &block)
@app || Sinatra::Application
end
+ def last_request?
+ last_request
+ true
+ rescue Rack::Test::Error
+ false
+ end
+
+ def session
+ return {} unless last_request?
+ raise Rack::Test:Error, "session not enabled for app" unless last_env["rack.session"] or app.session?
+ last_env["rack.session"]
+ end
+
+ def last_env
+ last_request.env
+ end
+
def define_route(verb, *args, &block)
app.send(verb, *args, &block)
end

0 comments on commit 1cdb894

Please sign in to comment.