Casecommons / with_model

Dynamically build an Active Record model (with table) within a test context
http://www.casebook.net
MIT License
167 stars 18 forks source link

Specs don't run in Ruby 3.1.0 - NoMethodError: super: no superclass method `descendants' for ActiveRecord::Base:Class #34

Closed nertzy closed 2 years ago

nertzy commented 2 years ago
❯ ruby -v
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin21]
❯ rspec --backtrace

An error occurred while loading ./spec/active_record_behaviors_spec.rb.
Failure/Error: ActiveRecord::Base.establish_connection(adapter: adapter, database: ':memory:')

NoMethodError:
  super: no superclass method `descendants' for ActiveRecord::Base:Class
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activerecord-7.0.0/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.0/lib/active_support/descendants_tracker.rb:90:in `descendants'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.0/lib/active_support/callbacks.rb:923:in `block in define_callbacks'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.0/lib/active_support/callbacks.rb:920:in `each'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.0/lib/active_support/callbacks.rb:920:in `define_callbacks'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activemodel-7.0.0/lib/active_model/validations.rb:50:in `block in <module:Validations>'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.0/lib/active_support/concern.rb:136:in `class_eval'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.0/lib/active_support/concern.rb:136:in `append_features'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.0/lib/active_support/concern.rb:133:in `include'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.0/lib/active_support/concern.rb:133:in `block in append_features'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.0/lib/active_support/concern.rb:133:in `each'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.0/lib/active_support/concern.rb:133:in `append_features'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activerecord-7.0.0/lib/active_record/base.rb:309:in `include'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activerecord-7.0.0/lib/active_record/base.rb:309:in `<class:Base>'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activerecord-7.0.0/lib/active_record/base.rb:282:in `<module:ActiveRecord>'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activerecord-7.0.0/lib/active_record/base.rb:15:in `<top (required)>'
# ./spec/spec_helper.rb:29:in `require'
# ./spec/spec_helper.rb:29:in `<top (required)>'
# <internal:/Users/grant/.rbenv/versions/3.1.0/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
# <internal:/Users/grant/.rbenv/versions/3.1.0/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
# ./spec/active_record_behaviors_spec.rb:3:in `<top (required)>'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:2112:in `load'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:2112:in `load_file_handling_errors'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1615:in `block in load_spec_files'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1613:in `each'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1613:in `load_spec_files'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:102:in `setup'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:86:in `run'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:71:in `run'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:45:in `invoke'
# /Users/grant/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/rspec-core-3.10.1/exe/rspec:4:in `<top (required)>'
# /Users/grant/.rbenv/versions/3.1.0/bin/rspec:25:in `load'
# /Users/grant/.rbenv/versions/3.1.0/bin/rspec:25:in `<main>'
nertzy commented 2 years ago

Related: https://github.com/rails/rails/pull/43951

yahonda commented 2 years ago

Rails 7.0.1 addresses this error https://rubyonrails.org/2022/1/6/Rails-7-0-1-has-been-released .

nertzy commented 2 years ago

Fixed in 2.1.6.