0

在 Windows 10 上,使用新的 Rails 7 应用程序和空的系统测试,当我运行系统测试时:

rails test test/system/empty_test.rb,我收到以下错误:

C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:46:in `connect_nonblock': SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate) (OpenSSL::SSL::SSLError)

        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:46:in `ssl_socket_connect'
        from C:/Ruby30-x64/lib/ruby/3.0.0/net/http.rb:1038:in `connect'
        from C:/Ruby30-x64/lib/ruby/3.0.0/net/http.rb:970:in `do_start'
        from C:/Ruby30-x64/lib/ruby/3.0.0/net/http.rb:959:in `start'
        from C:/Ruby30-x64/lib/ruby/3.0.0/net/http.rb:621:in `start'
        from C:/Ruby30-x64/lib/ruby/3.0.0/net/http.rb:496:in `get_response'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/network.rb:33:in `get_response'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/network.rb:14:in `get'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/chromedriver.rb:66:in `latest_point_release'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/chromedriver.rb:39:in `block in latest_version'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/common.rb:166:in `with_cache'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/chromedriver.rb:37:in `latest_version'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/common.rb:122:in `download_version'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/common.rb:134:in `correct_binary?'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/common.rb:91:in `update'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/webdrivers-5.0.0/lib/webdrivers/chromedriver.rb:149:in `block in <main>'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/system_testing/browser.rb:36:in `preload'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/system_testing/driver.rb:27:in `initialize'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/system_test_case.rb:159:in `new'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/system_test_case.rb:159:in `driven_by'
        from G:/webshop/test/application_system_test_case.rb:4:in `<class:ApplicationSystemTestCase>'
        from G:/webshop/test/application_system_test_case.rb:3:in `<main>'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
        from G:/webshop/test/system/empty_test.rb:1:in `<main>'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/test_unit/runner.rb:47:in `block in load_tests'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/test_unit/runner.rb:47:in `each'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/test_unit/runner.rb:47:in `load_tests'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/test_unit/runner.rb:40:in `run'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/commands/test/test_command.rb:33:in `perform'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/command/base.rb:87:in `perform'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/command.rb:48:in `invoke'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/commands.rb:18:in `<main>'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
        from bin/rails:4:in `<main>'

我不确定代码在寻找什么证书,它只是一个新站点,我从 localhost:3000 本地访问它。

这是空系统测试的代码:

require "application_system_test_case"

class EmptyTest < ApplicationSystemTestCase
end

我使用空测试只是为了确保不是测试代码导致了错误。

这是我的问题:

  1. Rails 系统测试正在寻找哪个证书?
  2. 我该如何解决?
4

1 回答 1

0

Rails 文档应该在系统测试部分记录这一点。

当我们使用默认设置进行系统测试时:

driven_by :selenium, using: :chrome, screen_size: [1400, 1400]

应定义系统环境变量 SSL_CERT_FILE。

我遵循了这个线程中的答案:

在 Windows 上的 ruby​​ 中出现 SSL 错误

它立即开始工作。

于 2022-01-21T22:55:48.913 回答