【问题标题】:rails rspec integration_tests and http authenticationrails rspec integration_tests 和 http 身份验证
【发布时间】:2013-07-21 23:57:34
【问题描述】:

我正在使用 Rspec 2 和 capybara 并定义了基本的集成测试,即

describe "EeRequisitions" do
  describe "GET /ee_requisitions" do
    it "works! (now write some real specs)" do
      get ee_requisitions_path
      response.status.should be(200)
    end
  end
end

由于应用程序使用 HTTP 基本身份验证,并且由于 capybara 说它包含 Rack::Test,我希望添加以下行:

authorize 'user', 'password'

会处理它(我已经丢失了告诉我的 stackoverflow 帖子)。不幸的是,它没有——它一直抛出“未找到方法”错误。我终于在这篇帖子的评论中找到了解决方案:Rails/Rspec Make tests pass with http basic authentication,Matt Connelly 向我指出了这个要点:https://gist.github.com/mattconnolly/4158961,它终于解决了我的问题。

但是,我仍然想知道为什么 Rack::Test 方法失败了,因为它似乎对其他人有效。

【问题讨论】:

    标签: ruby-on-rails-3 rspec basic-authentication


    【解决方案1】:

    是否包括行

    include Rack::Test::Methods
    

    在顶部的测试有什么不同?

    【讨论】:

    • 对不起,没有。不仅该测试仍然失败,而且该组中的所有其他测试现在也失败并显示以下消息: undefined local variable or method `app' for #<0x000000049293a8>
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-23
    • 2014-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多