Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added helper for session

  • Loading branch information...
commit 1cdb894fd7890a1c7b9945aecda0a682bad9af2a 1 parent 7651d48
@rkh authored
Showing with 17 additions and 0 deletions.
  1. +17 −0 lib/sinatra/test_helper.rb
View
17 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
Please sign in to comment.
Something went wrong with that request. Please try again.