How to test Sinatra application which is using session?
get "/", {}, {\'rack.session\' => { \'foo\' => \'blah\' } }
This cod
Just ran into this problem and the solution is simply the order of requiring the files, so @fguillen was correct. At the top of your spec, make sure you require rack/test before your sinatra app, so at a minimum, this should get you started:
# in myapp_spec.rb
require 'rspec'
require 'rack/test'
require 'myapp'
it "should set the session params" do
get 'users/current/projects', {}, 'rack.session' => {:user =>'1234'}
end
# in myapp.rb
enable :sessions
get 'users/current/projects' do
p env['rack.session']
end