我对我的工作rails应用程序进行了以下集成测试并且它通过了。但是,我有以下与此集成测试相关的问题:
request.original_url
会打印http://www.example.com
?不应该打印localhost:3000
,因为它是应用程序运行的默认端口吗?www.abcd.com
,并看到它失败,因为这样的主机甚至不存在?使用以下命令运行集成测试:
rake test:integration TEST=test/integration/login_test.rb
请指导。
require 'integration_test_helper'
class LoginTest < ActionDispatch::IntegrationTest
setup do
@user = users(:admin)
end
test "login page is displayed on root path" do
delete '/signout'
get root_path
puts root_path
puts request.original_url
assert redirect?
assert_redirected_to '/signin'
follow_redirect!
assert_template :new
assert_template %r{\Adevise/sessions/new\Z}
assert_select "a[href=?]", users_path, count: 0
assert_select "input[id=?]", 'login-email', count: 1
assert_select "input[id=?]", 'login-password', count: 1
assert_select "button[id=?]", 'login', count: 1
end
end