【发布时间】:2015-11-22 05:16:14
【问题描述】:
我在查看 RailsGuides 并看到了这个示例:
require 'test_helper'
class UserFlowsTest < ActionDispatch::IntegrationTest
test "login and browse site" do
# login via https
https!
get "/login"
assert_response :success
post_via_redirect "/login", username: users(:david).username, password: users(:david).password
assert_equal '/welcome', path
assert_equal 'Welcome david!', flash[:notice]
https!(false)
get "/articles/all"
assert_response :success
assert assigns(:articles)
end
end
我对@987654322@ 行中的变量“路径”感到困惑。这究竟是什么?这是我们在它之前执行post_via_redirect 操作后将显示在您的浏览器中的网址吗?
我查看了集成测试中可用的助手,但文档没有说明这个“路径”变量。
此外,我在我的 rails 应用程序上尝试了它,它工作正常,但是当我尝试在我的控制器测试之一中调用它时,它给了我和 undefined local variables or method 错误。那么这是否意味着“路径”变量仅在集成测试中可用?如果我想在其他类型的测试中使用它怎么办?
【问题讨论】:
标签: ruby-on-rails unit-testing integration-testing