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

送分小仙女□ 提交于 2019-12-12 03:55:51

问题


How can I make sessions work in my RSpec tests?

I have 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 a noob to sinatra, so I might be on the wrong track here...


回答1:


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

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



来源:https://stackoverflow.com/questions/3882029/how-can-i-make-racksessionpool-work-in-a-test-using-sinatra-and-rspec

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!