rubocop-rspec 2.16.0 → 2.24.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +124 -9
  3. data/README.md +3 -3
  4. data/config/default.yml +145 -18
  5. data/config/obsoletion.yml +15 -0
  6. data/lib/rubocop/cop/rspec/be_empty.rb +44 -0
  7. data/lib/rubocop/cop/rspec/be_nil.rb +2 -2
  8. data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +29 -115
  9. data/lib/rubocop/cop/rspec/capybara/match_style.rb +38 -0
  10. data/lib/rubocop/cop/rspec/capybara/negation_matcher.rb +23 -96
  11. data/lib/rubocop/cop/rspec/capybara/specific_actions.rb +19 -75
  12. data/lib/rubocop/cop/rspec/capybara/specific_finders.rb +14 -83
  13. data/lib/rubocop/cop/rspec/capybara/specific_matcher.rb +25 -69
  14. data/lib/rubocop/cop/rspec/capybara/visibility_matcher.rb +26 -63
  15. data/lib/rubocop/cop/rspec/change_by_zero.rb +33 -23
  16. data/lib/rubocop/cop/rspec/contain_exactly.rb +56 -0
  17. data/lib/rubocop/cop/rspec/context_method.rb +5 -1
  18. data/lib/rubocop/cop/rspec/context_wording.rb +13 -6
  19. data/lib/rubocop/cop/rspec/describe_method.rb +16 -8
  20. data/lib/rubocop/cop/rspec/described_class.rb +2 -1
  21. data/lib/rubocop/cop/rspec/described_class_module_wrapping.rb +7 -5
  22. data/lib/rubocop/cop/rspec/dialect.rb +1 -1
  23. data/lib/rubocop/cop/rspec/duplicated_metadata.rb +2 -2
  24. data/lib/rubocop/cop/rspec/empty_example_group.rb +10 -7
  25. data/lib/rubocop/cop/rspec/empty_hook.rb +2 -2
  26. data/lib/rubocop/cop/rspec/empty_line_after_example_group.rb +1 -1
  27. data/lib/rubocop/cop/rspec/empty_metadata.rb +46 -0
  28. data/lib/rubocop/cop/rspec/eq.rb +47 -0
  29. data/lib/rubocop/cop/rspec/example_wording.rb +1 -1
  30. data/lib/rubocop/cop/rspec/excessive_docstring_spacing.rb +14 -5
  31. data/lib/rubocop/cop/rspec/expect_actual.rb +4 -4
  32. data/lib/rubocop/cop/rspec/expect_in_hook.rb +1 -1
  33. data/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb +25 -118
  34. data/lib/rubocop/cop/rspec/factory_bot/consistent_parentheses_style.rb +40 -107
  35. data/lib/rubocop/cop/rspec/factory_bot/create_list.rb +30 -250
  36. data/lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb +19 -46
  37. data/lib/rubocop/cop/rspec/factory_bot/factory_name_style.rb +23 -64
  38. data/lib/rubocop/cop/rspec/factory_bot/syntax_methods.rb +45 -79
  39. data/lib/rubocop/cop/rspec/file_path.rb +8 -2
  40. data/lib/rubocop/cop/rspec/focus.rb +19 -5
  41. data/lib/rubocop/cop/rspec/hook_argument.rb +12 -9
  42. data/lib/rubocop/cop/rspec/hooks_before_examples.rb +5 -3
  43. data/lib/rubocop/cop/rspec/indexed_let.rb +112 -0
  44. data/lib/rubocop/cop/rspec/instance_variable.rb +1 -1
  45. data/lib/rubocop/cop/rspec/leaky_constant_declaration.rb +1 -1
  46. data/lib/rubocop/cop/rspec/let_before_examples.rb +8 -4
  47. data/lib/rubocop/cop/rspec/let_setup.rb +6 -8
  48. data/lib/rubocop/cop/rspec/match_array.rb +59 -0
  49. data/lib/rubocop/cop/rspec/metadata_style.rb +197 -0
  50. data/lib/rubocop/cop/rspec/mixin/empty_line_separation.rb +1 -2
  51. data/lib/rubocop/cop/rspec/mixin/file_help.rb +14 -0
  52. data/lib/rubocop/cop/rspec/mixin/location_help.rb +37 -0
  53. data/lib/rubocop/cop/rspec/mixin/metadata.rb +21 -7
  54. data/lib/rubocop/cop/rspec/mixin/skip_or_pending.rb +20 -4
  55. data/lib/rubocop/cop/rspec/multiple_expectations.rb +2 -1
  56. data/lib/rubocop/cop/rspec/named_subject.rb +7 -5
  57. data/lib/rubocop/cop/rspec/no_expectation_example.rb +2 -5
  58. data/lib/rubocop/cop/rspec/overwriting_setup.rb +3 -1
  59. data/lib/rubocop/cop/rspec/pending.rb +23 -13
  60. data/lib/rubocop/cop/rspec/pending_without_reason.rb +72 -36
  61. data/lib/rubocop/cop/rspec/predicate_matcher.rb +49 -40
  62. data/lib/rubocop/cop/rspec/rails/have_http_status.rb +11 -6
  63. data/lib/rubocop/cop/rspec/rails/http_status.rb +107 -34
  64. data/lib/rubocop/cop/rspec/rails/inferred_spec_type.rb +4 -4
  65. data/lib/rubocop/cop/rspec/rails/minitest_assertions.rb +60 -0
  66. data/lib/rubocop/cop/rspec/rails/negation_be_valid.rb +102 -0
  67. data/lib/rubocop/cop/rspec/rails/travel_around.rb +92 -0
  68. data/lib/rubocop/cop/rspec/receive_counts.rb +1 -1
  69. data/lib/rubocop/cop/rspec/receive_messages.rb +161 -0
  70. data/lib/rubocop/cop/rspec/redundant_around.rb +65 -0
  71. data/lib/rubocop/cop/rspec/repeated_example_group_body.rb +3 -6
  72. data/lib/rubocop/cop/rspec/repeated_example_group_description.rb +3 -6
  73. data/lib/rubocop/cop/rspec/repeated_include_example.rb +3 -4
  74. data/lib/rubocop/cop/rspec/scattered_setup.rb +23 -6
  75. data/lib/rubocop/cop/rspec/shared_context.rb +12 -13
  76. data/lib/rubocop/cop/rspec/shared_examples.rb +6 -4
  77. data/lib/rubocop/cop/rspec/skip_block_inside_example.rb +46 -0
  78. data/lib/rubocop/cop/rspec/sort_metadata.rb +4 -3
  79. data/lib/rubocop/cop/rspec/spec_file_path_format.rb +133 -0
  80. data/lib/rubocop/cop/rspec/spec_file_path_suffix.rb +40 -0
  81. data/lib/rubocop/cop/rspec/stubbed_mock.rb +1 -1
  82. data/lib/rubocop/cop/rspec/subject_stub.rb +0 -1
  83. data/lib/rubocop/cop/rspec/variable_definition.rb +5 -2
  84. data/lib/rubocop/cop/rspec/variable_name.rb +4 -1
  85. data/lib/rubocop/cop/rspec/verified_double_reference.rb +7 -7
  86. data/lib/rubocop/cop/rspec/verified_doubles.rb +1 -1
  87. data/lib/rubocop/cop/rspec/void_expect.rb +2 -1
  88. data/lib/rubocop/cop/rspec_cops.rb +16 -0
  89. data/lib/rubocop/rspec/config_formatter.rb +16 -0
  90. data/lib/rubocop/rspec/example_group.rb +6 -8
  91. data/lib/rubocop/rspec/language/node_pattern.rb +26 -0
  92. data/lib/rubocop/rspec/language.rb +25 -16
  93. data/lib/rubocop/rspec/version.rb +1 -1
  94. data/lib/rubocop-rspec.rb +4 -5
  95. metadata +50 -8
  96. data/lib/rubocop/cop/rspec/mixin/capybara_help.rb +0 -80
  97. data/lib/rubocop/cop/rspec/mixin/css_selector.rb +0 -146
  98. data/lib/rubocop/rspec/factory_bot/language.rb +0 -37
  99. data/lib/rubocop/rspec/factory_bot.rb +0 -64
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.16.0
4
+ version: 2.24.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Backus
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-12-13 00:00:00.000000000 Z
13
+ date: 2023-09-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -26,6 +26,34 @@ dependencies:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
28
  version: '1.33'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rubocop-capybara
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '2.17'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '2.17'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rubocop-factory_bot
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '2.22'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '2.22'
29
57
  description: |2
30
58
  Code style checking for RSpec files.
31
59
  A plugin for the RuboCop code style enforcing & linting tool.
@@ -52,12 +80,14 @@ files:
52
80
  - lib/rubocop/cop/rspec/around_block.rb
53
81
  - lib/rubocop/cop/rspec/base.rb
54
82
  - lib/rubocop/cop/rspec/be.rb
83
+ - lib/rubocop/cop/rspec/be_empty.rb
55
84
  - lib/rubocop/cop/rspec/be_eq.rb
56
85
  - lib/rubocop/cop/rspec/be_eql.rb
57
86
  - lib/rubocop/cop/rspec/be_nil.rb
58
87
  - lib/rubocop/cop/rspec/before_after_all.rb
59
88
  - lib/rubocop/cop/rspec/capybara/current_path_expectation.rb
60
89
  - lib/rubocop/cop/rspec/capybara/feature_methods.rb
90
+ - lib/rubocop/cop/rspec/capybara/match_style.rb
61
91
  - lib/rubocop/cop/rspec/capybara/negation_matcher.rb
62
92
  - lib/rubocop/cop/rspec/capybara/specific_actions.rb
63
93
  - lib/rubocop/cop/rspec/capybara/specific_finders.rb
@@ -65,6 +95,7 @@ files:
65
95
  - lib/rubocop/cop/rspec/capybara/visibility_matcher.rb
66
96
  - lib/rubocop/cop/rspec/change_by_zero.rb
67
97
  - lib/rubocop/cop/rspec/class_check.rb
98
+ - lib/rubocop/cop/rspec/contain_exactly.rb
68
99
  - lib/rubocop/cop/rspec/context_method.rb
69
100
  - lib/rubocop/cop/rspec/context_wording.rb
70
101
  - lib/rubocop/cop/rspec/describe_class.rb
@@ -81,6 +112,8 @@ files:
81
112
  - lib/rubocop/cop/rspec/empty_line_after_final_let.rb
82
113
  - lib/rubocop/cop/rspec/empty_line_after_hook.rb
83
114
  - lib/rubocop/cop/rspec/empty_line_after_subject.rb
115
+ - lib/rubocop/cop/rspec/empty_metadata.rb
116
+ - lib/rubocop/cop/rspec/eq.rb
84
117
  - lib/rubocop/cop/rspec/example_length.rb
85
118
  - lib/rubocop/cop/rspec/example_without_description.rb
86
119
  - lib/rubocop/cop/rspec/example_wording.rb
@@ -103,6 +136,7 @@ files:
103
136
  - lib/rubocop/cop/rspec/implicit_block_expectation.rb
104
137
  - lib/rubocop/cop/rspec/implicit_expect.rb
105
138
  - lib/rubocop/cop/rspec/implicit_subject.rb
139
+ - lib/rubocop/cop/rspec/indexed_let.rb
106
140
  - lib/rubocop/cop/rspec/instance_spy.rb
107
141
  - lib/rubocop/cop/rspec/instance_variable.rb
108
142
  - lib/rubocop/cop/rspec/it_behaves_like.rb
@@ -111,16 +145,18 @@ files:
111
145
  - lib/rubocop/cop/rspec/leaky_constant_declaration.rb
112
146
  - lib/rubocop/cop/rspec/let_before_examples.rb
113
147
  - lib/rubocop/cop/rspec/let_setup.rb
148
+ - lib/rubocop/cop/rspec/match_array.rb
114
149
  - lib/rubocop/cop/rspec/message_chain.rb
115
150
  - lib/rubocop/cop/rspec/message_expectation.rb
116
151
  - lib/rubocop/cop/rspec/message_spies.rb
152
+ - lib/rubocop/cop/rspec/metadata_style.rb
117
153
  - lib/rubocop/cop/rspec/missing_example_group_argument.rb
118
- - lib/rubocop/cop/rspec/mixin/capybara_help.rb
119
154
  - lib/rubocop/cop/rspec/mixin/comments_help.rb
120
- - lib/rubocop/cop/rspec/mixin/css_selector.rb
121
155
  - lib/rubocop/cop/rspec/mixin/empty_line_separation.rb
156
+ - lib/rubocop/cop/rspec/mixin/file_help.rb
122
157
  - lib/rubocop/cop/rspec/mixin/final_end_location.rb
123
158
  - lib/rubocop/cop/rspec/mixin/inside_example_group.rb
159
+ - lib/rubocop/cop/rspec/mixin/location_help.rb
124
160
  - lib/rubocop/cop/rspec/mixin/metadata.rb
125
161
  - lib/rubocop/cop/rspec/mixin/namespace.rb
126
162
  - lib/rubocop/cop/rspec/mixin/skip_or_pending.rb
@@ -142,8 +178,13 @@ files:
142
178
  - lib/rubocop/cop/rspec/rails/have_http_status.rb
143
179
  - lib/rubocop/cop/rspec/rails/http_status.rb
144
180
  - lib/rubocop/cop/rspec/rails/inferred_spec_type.rb
181
+ - lib/rubocop/cop/rspec/rails/minitest_assertions.rb
182
+ - lib/rubocop/cop/rspec/rails/negation_be_valid.rb
183
+ - lib/rubocop/cop/rspec/rails/travel_around.rb
145
184
  - lib/rubocop/cop/rspec/receive_counts.rb
185
+ - lib/rubocop/cop/rspec/receive_messages.rb
146
186
  - lib/rubocop/cop/rspec/receive_never.rb
187
+ - lib/rubocop/cop/rspec/redundant_around.rb
147
188
  - lib/rubocop/cop/rspec/repeated_description.rb
148
189
  - lib/rubocop/cop/rspec/repeated_example.rb
149
190
  - lib/rubocop/cop/rspec/repeated_example_group_body.rb
@@ -155,7 +196,10 @@ files:
155
196
  - lib/rubocop/cop/rspec/shared_context.rb
156
197
  - lib/rubocop/cop/rspec/shared_examples.rb
157
198
  - lib/rubocop/cop/rspec/single_argument_message_chain.rb
199
+ - lib/rubocop/cop/rspec/skip_block_inside_example.rb
158
200
  - lib/rubocop/cop/rspec/sort_metadata.rb
201
+ - lib/rubocop/cop/rspec/spec_file_path_format.rb
202
+ - lib/rubocop/cop/rspec/spec_file_path_suffix.rb
159
203
  - lib/rubocop/cop/rspec/stubbed_mock.rb
160
204
  - lib/rubocop/cop/rspec/subject_declaration.rb
161
205
  - lib/rubocop/cop/rspec/subject_stub.rb
@@ -175,8 +219,6 @@ files:
175
219
  - lib/rubocop/rspec/description_extractor.rb
176
220
  - lib/rubocop/rspec/example.rb
177
221
  - lib/rubocop/rspec/example_group.rb
178
- - lib/rubocop/rspec/factory_bot.rb
179
- - lib/rubocop/rspec/factory_bot/language.rb
180
222
  - lib/rubocop/rspec/hook.rb
181
223
  - lib/rubocop/rspec/inject.rb
182
224
  - lib/rubocop/rspec/language.rb
@@ -200,14 +242,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
242
  requirements:
201
243
  - - ">="
202
244
  - !ruby/object:Gem::Version
203
- version: 2.6.0
245
+ version: 2.7.0
204
246
  required_rubygems_version: !ruby/object:Gem::Requirement
205
247
  requirements:
206
248
  - - ">="
207
249
  - !ruby/object:Gem::Version
208
250
  version: '0'
209
251
  requirements: []
210
- rubygems_version: 3.1.6
252
+ rubygems_version: 3.4.12
211
253
  signing_key:
212
254
  specification_version: 4
213
255
  summary: Code style checking for RSpec files
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module RSpec
6
- # Help methods for capybara.
7
- module CapybaraHelp
8
- module_function
9
-
10
- # @param node [RuboCop::AST::SendNode]
11
- # @param locator [String]
12
- # @param element [String]
13
- # @return [Boolean]
14
- def specific_option?(node, locator, element)
15
- attrs = CssSelector.attributes(locator).keys
16
- return false unless replaceable_element?(node, element, attrs)
17
-
18
- attrs.all? do |attr|
19
- CssSelector.specific_options?(element, attr)
20
- end
21
- end
22
-
23
- # @param locator [String]
24
- # @return [Boolean]
25
- def specific_pseudo_classes?(locator)
26
- CssSelector.pseudo_classes(locator).all? do |pseudo_class|
27
- replaceable_pseudo_class?(pseudo_class, locator)
28
- end
29
- end
30
-
31
- # @param pseudo_class [String]
32
- # @param locator [String]
33
- # @return [Boolean]
34
- def replaceable_pseudo_class?(pseudo_class, locator)
35
- return false unless CssSelector.specific_pesudo_classes?(pseudo_class)
36
-
37
- case pseudo_class
38
- when 'not()' then replaceable_pseudo_class_not?(locator)
39
- else true
40
- end
41
- end
42
-
43
- # @param locator [String]
44
- # @return [Boolean]
45
- def replaceable_pseudo_class_not?(locator)
46
- locator.scan(/not\(.*?\)/).all? do |negation|
47
- CssSelector.attributes(negation).values.all? do |v|
48
- v.is_a?(TrueClass) || v.is_a?(FalseClass)
49
- end
50
- end
51
- end
52
-
53
- # @param node [RuboCop::AST::SendNode]
54
- # @param element [String]
55
- # @param attrs [Array<String>]
56
- # @return [Boolean]
57
- def replaceable_element?(node, element, attrs)
58
- case element
59
- when 'link' then replaceable_to_link?(node, attrs)
60
- else true
61
- end
62
- end
63
-
64
- # @param node [RuboCop::AST::SendNode]
65
- # @param attrs [Array<String>]
66
- # @return [Boolean]
67
- def replaceable_to_link?(node, attrs)
68
- include_option?(node, :href) || attrs.include?('href')
69
- end
70
-
71
- # @param node [RuboCop::AST::SendNode]
72
- # @param option [Symbol]
73
- # @return [Boolean]
74
- def include_option?(node, option)
75
- node.each_descendant(:sym).find { |opt| opt.value == option }
76
- end
77
- end
78
- end
79
- end
80
- end
@@ -1,146 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module RSpec
6
- # Helps parsing css selector.
7
- module CssSelector
8
- COMMON_OPTIONS = %w[
9
- above below left_of right_of near count minimum maximum between text
10
- id class style visible obscured exact exact_text normalize_ws match
11
- wait filter_set focused
12
- ].freeze
13
- SPECIFIC_OPTIONS = {
14
- 'button' => (
15
- COMMON_OPTIONS + %w[disabled name value title type]
16
- ).freeze,
17
- 'link' => (
18
- COMMON_OPTIONS + %w[href alt title download]
19
- ).freeze,
20
- 'table' => (
21
- COMMON_OPTIONS + %w[
22
- caption with_cols cols with_rows rows
23
- ]
24
- ).freeze,
25
- 'select' => (
26
- COMMON_OPTIONS + %w[
27
- disabled name placeholder options enabled_options
28
- disabled_options selected with_selected multiple with_options
29
- ]
30
- ).freeze,
31
- 'field' => (
32
- COMMON_OPTIONS + %w[
33
- checked unchecked disabled valid name placeholder
34
- validation_message readonly with type multiple
35
- ]
36
- ).freeze
37
- }.freeze
38
- SPECIFIC_PSEUDO_CLASSES = %w[
39
- not() disabled enabled checked unchecked
40
- ].freeze
41
-
42
- module_function
43
-
44
- # @param element [String]
45
- # @param attribute [String]
46
- # @return [Boolean]
47
- # @example
48
- # specific_pesudo_classes?('button', 'name') # => true
49
- # specific_pesudo_classes?('link', 'invalid') # => false
50
- def specific_options?(element, attribute)
51
- SPECIFIC_OPTIONS.fetch(element, []).include?(attribute)
52
- end
53
-
54
- # @param pseudo_class [String]
55
- # @return [Boolean]
56
- # @example
57
- # specific_pesudo_classes?('disabled') # => true
58
- # specific_pesudo_classes?('first-of-type') # => false
59
- def specific_pesudo_classes?(pseudo_class)
60
- SPECIFIC_PSEUDO_CLASSES.include?(pseudo_class)
61
- end
62
-
63
- # @param selector [String]
64
- # @return [Boolean]
65
- # @example
66
- # id?('#some-id') # => true
67
- # id?('.some-class') # => false
68
- def id?(selector)
69
- selector.start_with?('#')
70
- end
71
-
72
- # @param selector [String]
73
- # @return [Boolean]
74
- # @example
75
- # attribute?('[attribute]') # => true
76
- # attribute?('attribute') # => false
77
- def attribute?(selector)
78
- selector.start_with?('[')
79
- end
80
-
81
- # @param selector [String]
82
- # @return [Array<String>]
83
- # @example
84
- # attributes('a[foo-bar_baz]') # => {"foo-bar_baz=>true}
85
- # attributes('button[foo][bar]') # => {"foo"=>true, "bar"=>true}
86
- # attributes('table[foo=bar]') # => {"foo"=>"'bar'"}
87
- def attributes(selector)
88
- selector.scan(/\[(.*?)\]/).flatten.to_h do |attr|
89
- key, value = attr.split('=')
90
- [key, normalize_value(value)]
91
- end
92
- end
93
-
94
- # @param selector [String]
95
- # @return [Boolean]
96
- # @example
97
- # common_attributes?('a[focused]') # => true
98
- # common_attributes?('button[focused][visible]') # => true
99
- # common_attributes?('table[id=some-id]') # => true
100
- # common_attributes?('h1[invalid]') # => false
101
- def common_attributes?(selector)
102
- attributes(selector).keys.difference(COMMON_OPTIONS).none?
103
- end
104
-
105
- # @param selector [String]
106
- # @return [Array<String>]
107
- # @example
108
- # pseudo_classes('button:not([disabled])') # => ['not()']
109
- # pseudo_classes('a:enabled:not([valid])') # => ['enabled', 'not()']
110
- def pseudo_classes(selector)
111
- # Attributes must be excluded or else the colon in the `href`s URL
112
- # will also be picked up as pseudo classes.
113
- # "a:not([href='http://example.com']):enabled" => "a:not():enabled"
114
- ignored_attribute = selector.gsub(/\[.*?\]/, '')
115
- # "a:not():enabled" => ["not()", "enabled"]
116
- ignored_attribute.scan(/:([^:]*)/).flatten
117
- end
118
-
119
- # @param selector [String]
120
- # @return [Boolean]
121
- # @example
122
- # multiple_selectors?('a.cls b#id') # => true
123
- # multiple_selectors?('a.cls') # => false
124
- def multiple_selectors?(selector)
125
- selector.match?(/[ >,+~]/)
126
- end
127
-
128
- # @param value [String]
129
- # @return [Boolean, String]
130
- # @example
131
- # normalize_value('true') # => true
132
- # normalize_value('false') # => false
133
- # normalize_value(nil) # => false
134
- # normalize_value("foo") # => "'foo'"
135
- def normalize_value(value)
136
- case value
137
- when 'true' then true
138
- when 'false' then false
139
- when nil then true
140
- else "'#{value}'"
141
- end
142
- end
143
- end
144
- end
145
- end
146
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module RSpec
5
- module FactoryBot
6
- # Contains node matchers for common FactoryBot DSL.
7
- module Language
8
- extend RuboCop::NodePattern::Macros
9
-
10
- METHODS = %i[
11
- attributes_for
12
- attributes_for_list
13
- attributes_for_pair
14
- build
15
- build_list
16
- build_pair
17
- build_stubbed
18
- build_stubbed_list
19
- build_stubbed_pair
20
- create
21
- create_list
22
- create_pair
23
- generate
24
- generate_list
25
- null
26
- null_list
27
- null_pair
28
- ].to_set.freeze
29
-
30
- # @!method factory_bot?(node)
31
- def_node_matcher :factory_bot?, <<~PATTERN
32
- (const {nil? cbase} {:FactoryGirl :FactoryBot})
33
- PATTERN
34
- end
35
- end
36
- end
37
- end
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module RSpec
5
- # RuboCop FactoryBot project namespace
6
- module FactoryBot
7
- ATTRIBUTE_DEFINING_METHODS = %i[
8
- factory
9
- ignore
10
- trait
11
- traits_for_enum
12
- transient
13
- ].freeze
14
-
15
- UNPROXIED_METHODS = %i[
16
- __send__
17
- __id__
18
- nil?
19
- send
20
- object_id
21
- extend
22
- instance_eval
23
- initialize
24
- block_given?
25
- raise
26
- caller
27
- method
28
- ].freeze
29
-
30
- DEFINITION_PROXY_METHODS = %i[
31
- add_attribute
32
- after
33
- association
34
- before
35
- callback
36
- ignore
37
- initialize_with
38
- sequence
39
- skip_create
40
- to_create
41
- ].freeze
42
-
43
- RESERVED_METHODS =
44
- DEFINITION_PROXY_METHODS +
45
- UNPROXIED_METHODS +
46
- ATTRIBUTE_DEFINING_METHODS
47
-
48
- private_constant(
49
- :ATTRIBUTE_DEFINING_METHODS,
50
- :UNPROXIED_METHODS,
51
- :DEFINITION_PROXY_METHODS,
52
- :RESERVED_METHODS
53
- )
54
-
55
- def self.attribute_defining_methods
56
- ATTRIBUTE_DEFINING_METHODS
57
- end
58
-
59
- def self.reserved_methods
60
- RESERVED_METHODS
61
- end
62
- end
63
- end
64
- end