Ruby and Rack: Working with session
Rack is a very simple web server interface which you can use to build small web apps. One of the things that I really like about Rack is how minimalistic it is, which makes it a lot less intimidating than other web frameworks (e.g. rails)
This post will include a very small example on working with Rack’s session and how to unit test that the session has the correct values.
To write unit tests for rack, you need to include Rack::Test::Methods
. This provides several useful utility methods to test your rack application with.
Lets write a unit test that’ll test we can store an object in the session.
In order to get access to the session, we can use Rack::Request
that provides helper methods.