rails / rails-dom-testing

Extracting DomAssertions and SelectorAssertions from ActionView.
MIT License
175 stars 57 forks source link

uninitialized constant HTMLSelector::Minitest after update to 2.1.0 #107

Closed xxx closed 1 year ago

xxx commented 1 year ago

Hi, I'm doing some gem updates today, and starting seeing this when I try to run tests. rails-dom-testing is in our bundle as a dependency of other packages, but we do not use it ourselves directly.

Is there some new configuration I need to add? I didn't see anything documented.

full trace:

NameError:
  uninitialized constant HTMLSelector::Minitest
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/rails-dom-testing-2.1.0/lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb:7:in `<class:HTMLSelector>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/rails-dom-testing-2.1.0/lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb:4:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/rails-dom-testing-2.1.0/lib/rails/dom/testing/assertions/selector_assertions.rb:2:in `require_relative'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/rails-dom-testing-2.1.0/lib/rails/dom/testing/assertions/selector_assertions.rb:2:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/jquery-rails-4.5.1/lib/jquery/assert_select.rb:1:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/jquery-rails-4.5.1/lib/jquery/rails.rb:1:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/jquery-rails-4.5.1/lib/jquery-rails.rb:1:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/administrate-0.18.0/lib/administrate/engine.rb:1:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/administrate-0.18.0/lib/administrate.rb:1:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bundler-2.3.7/lib/bundler.rb:176:in `require'
# ./config/application.rb:16:in `<main>'
# ./config/environment.rb:3:in `require_relative'
# ./config/environment.rb:3:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# ./spec/rails_helper.rb:5:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# ./spec/services/workstreams/update_workstream_summary_schedule_spec.rb:3:in `<main>'
joeadcock commented 1 year ago

I am also getting the uninitialized constant HTMLSelector::Minitest errors when running RSpec tests. I have not able to replicate it on a new sample project though.

robbl commented 1 year ago

Im pretty sure the error was introduced with https://github.com/rails/rails-dom-testing/pull/106. The workaround is to require 'minitest' in your spec_helper.

iagopuccini commented 1 year ago

I'm also getting this error over here, I'm upgrading the Ruby version of an application, and this error was returned when bumping from Ruby version 2.6.8 to 2.6.9. During the execution of the tests I don't have any problems, but when running the server the error uninitialized constant HTMLSelector::Minitest is displayed.

heynan0 commented 1 year ago

I got the problem after upgrading dartsass-rails to 0.5.0, which somewhat triggered some additional upgrade on this gem, rails-dom-testing.

-    rails-dom-testing (2.0.3)
-      activesupport (>= 4.2.0)
+    rails-dom-testing (2.1.0)
+      activesupport (>= 5.0.0)
heynan0 commented 1 year ago

cc @rafaelfranca @flavorjones

iagopuccini commented 1 year ago

Hi, I'm doing some gem updates today, and starting seeing this when I try to run tests. rails-dom-testing is in our bundle as a dependency of other packages, but we do not use it ourselves directly.

Is there some new configuration I need to add? I didn't see anything documented.

full trace:

NameError:
  uninitialized constant HTMLSelector::Minitest
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/rails-dom-testing-2.1.0/lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb:7:in `<class:HTMLSelector>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/rails-dom-testing-2.1.0/lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb:4:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/rails-dom-testing-2.1.0/lib/rails/dom/testing/assertions/selector_assertions.rb:2:in `require_relative'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/rails-dom-testing-2.1.0/lib/rails/dom/testing/assertions/selector_assertions.rb:2:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/jquery-rails-4.5.1/lib/jquery/assert_select.rb:1:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/jquery-rails-4.5.1/lib/jquery/rails.rb:1:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/jquery-rails-4.5.1/lib/jquery-rails.rb:1:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/administrate-0.18.0/lib/administrate/engine.rb:1:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/administrate-0.18.0/lib/administrate.rb:1:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bundler-2.3.7/lib/bundler.rb:176:in `require'
# ./config/application.rb:16:in `<main>'
# ./config/environment.rb:3:in `require_relative'
# ./config/environment.rb:3:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# ./spec/rails_helper.rb:5:in `<main>'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /home/mpd/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# ./spec/services/workstreams/update_workstream_summary_schedule_spec.rb:3:in `<main>'

After performing some tests in my application, I was able to run the server again successfully, but I had to add the gem explicitly to

    group :test do 
      gem 'rails-dom-testing', '~> 2.0.3'
    end
joeadcock commented 1 year ago

it looks like adding jquery-rails to the Gemfile is an easy way to replicate the issue.

Here is a sample repo: https://github.com/joeadcock/rails-dom-testing-2.1.0-bug

xxx commented 1 year ago

@iagopuccini yeah, we're currently on 2.0.3 and it works, but locking to that version prevents a bunch of other gems from updating.

joeadcock commented 1 year ago

@xxx Adding gem 'rails-dom-testing', '< 2.1.0' should fix your immediate problem

xxx commented 1 year ago

@joeadcock thanks, that does work, though I guess I don't understand why specifying the version that way allows other gems to be updated, while locking to 2.0.3 doesn't.

joeadcock commented 1 year ago

@xxx Yeah, that is strange...

rafaelfranca commented 1 year ago

wow, that was quick. Thank you folks for reporting 2.1.1 should have fixed it. Let me know if it is still happening.

xxx commented 1 year ago

I can confirm that 2.1.1 fixes me. thanks!