rspec-description_consistency 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0f2e9e090d2bc3707eae5656451fcb48932777e8eee53d9efee4741ae04dfb2
4
- data.tar.gz: 8f9e93d88a4e81c1d9f7c30da88747db0a14f8b629dd488d0b0b9a9390140d6b
3
+ metadata.gz: ea1200d9bb0432aaf51947c5dc92b50a9c1709171b38e50beb9a583d5c8915c6
4
+ data.tar.gz: 65995762b57410b053e3353dfbf11a36b933a907945fc5de17bfe0ddab6cb441
5
5
  SHA512:
6
- metadata.gz: f8e9e8cdab51a8e86bf8dc611a9c9df71bea86161d4884914908b2b558ca8d409c284d1b39e35e1cba3612b85492b1b9436a77b50306c1c9546bacfa0e6dc266
7
- data.tar.gz: 832491c5965120ff2bdf6e4dabfa099a7b59f41b2f34860b638bfec96e676040708f9606c37681f8e601e5c84e678b6aa03a357a32bf5f7bfb88a3659afd7be4
6
+ metadata.gz: 20a9c5e7cb54039ad537f3275a7a75655ff49ccc507cbdfa3a34754186aafe4ae97e07a906302c3986aa5c65a2f8078322269f57d59fdacdbe509d6410801682
7
+ data.tar.gz: 31a0a471494a0a0cc33f881661b07271fb4fa386379744e66c8ec4b8337f17d890c47954f84a61776df4efee7b21df4946f19cb138b63ce451a05666e15e5bcf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2024-03-14
3
+ ## [1.0.2] - 2024-07-04
4
+
5
+ - Add support for `ActiveRecord` attributes [(#2)](https://github.com/viralpraxis/rspec-description_consistency/pull/2)
6
+
7
+ ## [1.0.1] - 2024-07-04
8
+
9
+ - Fix incorrect instance method check in case of dynamically defined methods [(#1)](https://github.com/viralpraxis/rspec-description_consistency/pull/1)
10
+
11
+ ## [1.0.0] - 2024-07-03
4
12
 
5
13
  - Initial release
data/README.md CHANGED
@@ -35,15 +35,13 @@ This gem enforces consistency by checking descriptions against the described obj
35
35
 
36
36
  ## Installation
37
37
 
38
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
39
-
40
38
  Install the gem and add to the application's Gemfile by executing:
41
39
 
42
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
40
+ $ bundle add rspec-description_consistency
43
41
 
44
42
  If bundler is not being used to manage dependencies, install the gem by executing:
45
43
 
46
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
44
+ $ gem install rspec-description_consistency
47
45
 
48
46
  ## Usage
49
47
 
@@ -43,24 +43,25 @@ module RSpec
43
43
  def correct_method_example_group?(description, klass, include_private:)
44
44
  method_name = description[1..].to_sym
45
45
 
46
- if description.start_with?('#') && include_private
47
- klass.method_defined?(method_name) || klass.private_method_defined?(method_name)
48
- elsif description.start_with?('#')
49
- klass.method_defined?(method_name)
46
+ if description.start_with?('#')
47
+ klass.instance_methods.include?(method_name)
48
+ elsif description.start_with?('#') && include_private
49
+ klass.private_instance_methods.include?(method_name) ||
50
+ (klass.respond_to?(:attribute_names) && klass.attribute_names.include?(method_name.to_s))
50
51
  elsif description.start_with?('.')
51
52
  correct_class_method?(method_name, klass, include_private: include_private)
52
53
  end
53
54
  end
54
55
 
55
56
  def correct_class_method?(method_name, klass, include_private:)
56
- klass.singleton_class.method_defined?(method_name) ||
57
+ klass.singleton_class.instance_methods.include?(method_name) ||
57
58
  (include_private && klass.singleton_class.private_instance_methods.include?(method_name)) ||
58
59
  activesupport_concern?(method_name, klass)
59
60
  end
60
61
 
61
62
  def activesupport_concern?(method_name, klass)
62
63
  if klass.is_a?(Module) && klass.const_defined?(:ClassMethods) &&
63
- klass.const_get(:ClassMethods).method_defined?(method_name)
64
+ klass.const_get(:ClassMethods).instance_methods.include?(method_name)
64
65
  true
65
66
  else
66
67
  Object.const_defined?(:ActiveSupport) && ::ActiveSupport.const_defined?(:Concern) &&
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rspec
4
4
  module DescriptionConsistency
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-description_consistency
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iaroslav Kurbatov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-03 00:00:00.000000000 Z
11
+ date: 2024-07-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Automatic checking of consistency of descriptions in context and describe
14
14
  blocks, and class or module methods.