I'm running a pretty simple test, which requires javascript, just to check the index loads and an element is there, something like:
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
My config for capybara looks like this (just getting rid of Puma boot logs):
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
And here's the error I'm getting:
#<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
I guess I've got an error to debug but the logger isn't working? If I change Silent: true
to Silent: False
, it gives me the same No Method Error for stdio
. So something must be wrong with Puma? I'm using rails (6.1.7), puma (6.0.0) and capybara (3.37.1).
I'm stumped.
CodePudding user response:
The released version of Capybara doesn’t support Puma 6. You can use the master branch of Capybara, use Puma 5.x, or write your own server registration config.
CodePudding user response:
I have same problem, just temporary downgrade Puma to version 5.x at the moment. If you also use capistrano3-puma, downgrade it to 5.x either.