diff --git a/lib/comma/header_extractor.rb b/lib/comma/header_extractor.rb index d6c2109..9a5a03a 100644 --- a/lib/comma/header_extractor.rb +++ b/lib/comma/header_extractor.rb @@ -45,7 +45,8 @@ def get_association_class(model_class, association) begin model_class.reflect_on_association(association)&.klass - rescue NameError + rescue ArgumentError, NameError + # Since Rails 5.2, ArgumentError is raised. nil end end diff --git a/spec/comma/rails/active_record_spec.rb b/spec/comma/rails/active_record_spec.rb index eedfb27..16f0554 100644 --- a/spec/comma/rails/active_record_spec.rb +++ b/spec/comma/rails/active_record_spec.rb @@ -144,8 +144,7 @@ def name describe 'github pull-request 83' do it 'should not raise NameError' do - expect { Picture.all.to_comma(:pr_83) } - .not_to raise_exception(NameError) + expect { Picture.all.to_comma(:pr_83) }.not_to raise_error end end end