如何使用 Sinatra 和 RSpec 使 Rack::Session::Pool 在测试中工作?
如何使会话在 RSpec 测试中正常工作?
我尝试过这样的事情:
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 的菜鸟,所以我可能走错了路......
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这解决了我的问题: http://gist.github.com/375973
不完全是我想要的,但是它在我的测试中有效。
This solved my problem: http://gist.github.com/375973
Not quite what I wanted, but it works in my tests.