From f519d0d4e004a86509981bc05458a1390407f222 Mon Sep 17 00:00:00 2001 From: viralpraxis Date: Tue, 13 Aug 2024 20:52:12 +0300 Subject: [PATCH] Fix `ActiveModel` attribute misdetection --- CHANGELOG.md | 4 ++++ Gemfile.lock | 2 +- lib/rspec/description_consistency/consitency_verifier.rb | 5 ++--- lib/rspec/description_consistency/version.rb | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e7d907..3bc0eb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## [Unreleased] +## [1.0.4] - 2024-08-13 + +- Fix `ActiveModel` attribute misdetection [(#4)](https://github.com/viralpraxis/rspec-description_consistency/pull/4) + ## [1.0.3] - 2024-07-04 - Fix invalid private method verification [(#3)](https://github.com/viralpraxis/rspec-description_consistency/pull/3) diff --git a/Gemfile.lock b/Gemfile.lock index 968c878..ab3a381 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - rspec-description_consistency (1.0.3) + rspec-description_consistency (1.0.4) GEM remote: https://rubygems.org/ diff --git a/lib/rspec/description_consistency/consitency_verifier.rb b/lib/rspec/description_consistency/consitency_verifier.rb index 55e6887..e74bc47 100644 --- a/lib/rspec/description_consistency/consitency_verifier.rb +++ b/lib/rspec/description_consistency/consitency_verifier.rb @@ -45,10 +45,9 @@ def correct_method_example_group?(description, klass, include_private:) if description.start_with?('#') return true if klass.instance_methods.include?(method_name) - return false unless include_private - return true if klass.private_instance_methods.include?(method_name) + return true if klass.respond_to?(:attribute_names) && klass.attribute_names.include?(method_name.to_s) - klass.respond_to?(:attribute_names) && klass.attribute_names.include?(method_name.to_s) + include_private && klass.private_instance_methods.include?(method_name) elsif description.start_with?('.') correct_class_method?(method_name, klass, include_private: include_private) end diff --git a/lib/rspec/description_consistency/version.rb b/lib/rspec/description_consistency/version.rb index 51dce0a..3c28bfd 100644 --- a/lib/rspec/description_consistency/version.rb +++ b/lib/rspec/description_consistency/version.rb @@ -2,6 +2,6 @@ module Rspec module DescriptionConsistency - VERSION = '1.0.3' + VERSION = '1.0.4' end end