How can I get Rack :: Session :: Pool to work in a test using Sinatra and RSpec?

How can I make sessions work in my RSpec tests?

I tried something like this:

describe "createnewlist_route_spec" do include Rack::Test::Methods use Rack::Session::Pool def app @app ||= Sinatra::Application end it "should save listitem to database" do post '/addnewlistitem', {:item => 'testitem'}, :sessions => {:userid => '123'} end end 

I'm noob sinatra, so maybe I'm wrong here ...

0
source share
1 answer

This solved my problem: http://gist.github.com/375973

Not quite what I wanted, but it works in my tests.

0
source

Source: https://habr.com/ru/post/1385165/


All Articles