如何使用 Sinatra 和 RSpec 使 Rack::Session::Pool 在测试中工作? [英] How can I make Rack::Session::Pool work in a test using Sinatra and RSpec?
本文介绍了如何使用 Sinatra 和 RSpec 使 Rack::Session::Pool 在测试中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使会话在我的 RSpec 测试中起作用?
How can I make sessions work in my RSpec tests?
我尝试过这样的事情:
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
我是 sinatra 的菜鸟,所以我可能在这里走错了路...
I'm a noob to sinatra, so I might be on the wrong track here...
推荐答案
这解决了我的问题:http://gist.github.com/375973
不是我想要的,但它在我的测试中有效.
Not quite what I wanted, but it works in my tests.
这篇关于如何使用 Sinatra 和 RSpec 使 Rack::Session::Pool 在测试中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文