我正在运行一个非常简单的测试,它需要javascript,只是为了检查索引加载和一个元素是否存在,类似于:
class ProfitsTest < ApplicationSystemTestCase
setup do
@admin = users(:admin)
@admin.confirm
sign_in @admin
end
test 'visiting the index' do
# Index only test
visit profits_url
assert_selector 'h1', text: '計算表'
end
end
我的配置水豚看起来像这样(只是摆脱Puma Boot 日志):
require 'test_helper'
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :headless_chrome # :chrome
Capybara.server = :puma, { Silent: true }
Selenium::WebDriver.logger.ignore(:browser_options)
end
下面是我得到的错误:
#<Thread:0x000000010f82b2d8 /Users/cody/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/capybara-3.37.1/lib/capybara/server.rb:76 run> terminated with exception (report_on_exception is true):
/Users/cody/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/capybara-3.37.1/lib/capybara/registrations/servers.rb:32:in `block in <main>': undefined method `strings' for Puma::Events:Class (NoMethodError)
events = conf.options[:Silent] ? ::Puma::Events.strings : ::Puma::Events.stdio
^^^^^^^^
from /Users/cody/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/capybara-3.37.1/lib/capybara/config.rb:64:in `block in server='
from /Users/cody/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/capybara-3.37.1/lib/capybara/server.rb:77:in `block in boot'
E
Error:
ProfitsTest#test_visiting_the_index:
NoMethodError: undefined method `strings' for Puma::Events:Class
/Users/cody/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/capybara-3.37.1/lib/capybara/registrations/servers.rb:32:in `block in <main>'
/Users/cody/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/capybara-3.37.1/lib/capybara/config.rb:64:in `block in server='
/Users/cody/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/capybara-3.37.1/lib/capybara/server.rb:77:in `block in boot'
Error:
ProfitsTest#test_visiting_the_index:
NoMethodError: undefined method `strings' for Puma::Events:Class
/Users/cody/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/capybara-3.37.1/lib/capybara/registrations/servers.rb:32:in `block in <main>'
/Users/cody/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/capybara-3.37.1/lib/capybara/config.rb:64:in `block in server='
/Users/cody/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/capybara-3.37.1/lib/capybara/server.rb:77:in `block in boot'
rails test test/system/profits_test.rb:20
我想我有一个错误要调试,但是记录器不工作了?如果我把Silent: true
改为Silent: False
,它会给我同样的stdio
的无方法错误。那么Puma一定有什么问题?我使用的是rails(6.1.7),puma(6.0.0)和capybara(3.37.1)。
我被难住了。
2条答案
按热度按时间mwyxok5s1#
发布的Capybara版本不支持Puma 6。您可以使用Capybara的主分支、Puma 5.x或编写自己的服务器注册配置。
omhiaaxx2#
我有同样的问题,只是暂时降级彪马到版本5. x的时刻。如果你也使用capistrano 3-彪马,降级到5. x也。