【发布时间】: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