active-hash / active_hash

A readonly ActiveRecord-esque base class that lets you use a hash, a Yaml file or a custom file as the datasource
MIT License
1.21k stars 179 forks source link

Support Ruby 3.3 #298

Closed m-nakamura145 closed 10 months ago

m-nakamura145 commented 10 months ago

In Ruby 3.3, the message format for NoMethodError has been changed. I have modified the expected values in the tests to maintain compatibility.

undefined local variable or method 'privatee' for class Foo (NoMethodError)

Ruby 3.2.2

❯ ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin22]

❯ bundle exec rspec spec/active_hash/base_spec.rb:956
Run options: include {:locations=>{"./spec/active_hash/base_spec.rb"=>[956]}}
.

Finished in 0.00241 seconds (files took 0.317 seconds to load)
1 example, 0 failures

Ruby 3.3.0

❯ ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin23]

❯ bundle exec rspec spec/active_hash/base_spec.rb:956
Run options: include {:locations=>{"./spec/active_hash/base_spec.rb"=>[956]}}
F

Failures:

  1) ActiveHash Base custom finders find_by_<field_one>_and_<field_two>! for fields the class doesn't have raises a NoMethodError
     Failure/Error:
       expect {
         Country.find_by_name_and_shoe_size!("US", 10)
       }.to raise_error(NoMethodError, /undefined method `find_by_name_and_shoe_size!' (?:for|on) Country/)

       expected NoMethodError with message matching /undefined method `find_by_name_and_shoe_size!' (?:for|on) Country/, got #<NoMethodError: undefined method `find_by_name_and_shoe_size!' for class Country> with backtrace:
         # ./lib/active_hash/base.rb:227:in `method_missing'
         # ./spec/active_hash/base_spec.rb:959:in `block (6 levels) in <top (required)>'
         # ./spec/active_hash/base_spec.rb:958:in `block (5 levels) in <top (required)>'
     # ./spec/active_hash/base_spec.rb:958:in `block (5 levels) in <top (required)>'

Finished in 0.01382 seconds (files took 0.38411 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/active_hash/base_spec.rb:957 # ActiveHash Base custom finders find_by_<field_one>_and_<field_two>! for fields the class doesn't have raises a NoMethodError