如何使用 Sinatra 和 RSpec 使 Rack::Session::Pool 在测试中工作?

发布于 2024-09-26 04:02:01 字数 407 浏览 0 评论 0原文

如何使会话在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

本王不退位尔等都是臣 2024-10-03 04:02:01

这解决了我的问题: 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文