rubocop-rspec 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/README.md +2 -2
  4. data/config/default.yml +2 -0
  5. data/lib/rubocop/cop/rspec/around_block.rb +2 -0
  6. data/lib/rubocop/cop/rspec/be.rb +1 -0
  7. data/lib/rubocop/cop/rspec/be_eql.rb +1 -0
  8. data/lib/rubocop/cop/rspec/before_after_all.rb +1 -0
  9. data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +3 -0
  10. data/lib/rubocop/cop/rspec/capybara/feature_methods.rb +3 -0
  11. data/lib/rubocop/cop/rspec/capybara/visibility_matcher.rb +2 -0
  12. data/lib/rubocop/cop/rspec/context_method.rb +1 -0
  13. data/lib/rubocop/cop/rspec/context_wording.rb +7 -1
  14. data/lib/rubocop/cop/rspec/describe_class.rb +3 -0
  15. data/lib/rubocop/cop/rspec/describe_method.rb +1 -0
  16. data/lib/rubocop/cop/rspec/describe_symbol.rb +1 -0
  17. data/lib/rubocop/cop/rspec/described_class.rb +5 -0
  18. data/lib/rubocop/cop/rspec/described_class_module_wrapping.rb +2 -1
  19. data/lib/rubocop/cop/rspec/dialect.rb +1 -0
  20. data/lib/rubocop/cop/rspec/empty_hook.rb +1 -0
  21. data/lib/rubocop/cop/rspec/example_length.rb +26 -12
  22. data/lib/rubocop/cop/rspec/example_without_description.rb +1 -0
  23. data/lib/rubocop/cop/rspec/example_wording.rb +1 -0
  24. data/lib/rubocop/cop/rspec/expect_actual.rb +1 -0
  25. data/lib/rubocop/cop/rspec/expect_change.rb +2 -0
  26. data/lib/rubocop/cop/rspec/expect_in_hook.rb +1 -0
  27. data/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb +3 -0
  28. data/lib/rubocop/cop/rspec/factory_bot/create_list.rb +3 -0
  29. data/lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb +1 -0
  30. data/lib/rubocop/cop/rspec/file_path.rb +2 -0
  31. data/lib/rubocop/cop/rspec/focus.rb +3 -0
  32. data/lib/rubocop/cop/rspec/hook_argument.rb +2 -0
  33. data/lib/rubocop/cop/rspec/hooks_before_examples.rb +1 -0
  34. data/lib/rubocop/cop/rspec/implicit_block_expectation.rb +3 -0
  35. data/lib/rubocop/cop/rspec/implicit_expect.rb +1 -0
  36. data/lib/rubocop/cop/rspec/implicit_subject.rb +1 -0
  37. data/lib/rubocop/cop/rspec/instance_spy.rb +2 -0
  38. data/lib/rubocop/cop/rspec/instance_variable.rb +4 -0
  39. data/lib/rubocop/cop/rspec/it_behaves_like.rb +1 -0
  40. data/lib/rubocop/cop/rspec/iterated_expectation.rb +2 -0
  41. data/lib/rubocop/cop/rspec/let_before_examples.rb +1 -0
  42. data/lib/rubocop/cop/rspec/let_setup.rb +3 -0
  43. data/lib/rubocop/cop/rspec/message_expectation.rb +2 -0
  44. data/lib/rubocop/cop/rspec/message_spies.rb +2 -0
  45. data/lib/rubocop/cop/rspec/mixin/variable.rb +1 -0
  46. data/lib/rubocop/cop/rspec/multiple_expectations.rb +3 -0
  47. data/lib/rubocop/cop/rspec/named_subject.rb +3 -0
  48. data/lib/rubocop/cop/rspec/not_to_not.rb +1 -0
  49. data/lib/rubocop/cop/rspec/overwriting_setup.rb +2 -0
  50. data/lib/rubocop/cop/rspec/pending.rb +4 -0
  51. data/lib/rubocop/cop/rspec/predicate_matcher.rb +5 -0
  52. data/lib/rubocop/cop/rspec/rails/http_status.rb +1 -0
  53. data/lib/rubocop/cop/rspec/receive_counts.rb +2 -0
  54. data/lib/rubocop/cop/rspec/receive_never.rb +1 -0
  55. data/lib/rubocop/cop/rspec/repeated_example_group_body.rb +8 -1
  56. data/lib/rubocop/cop/rspec/repeated_example_group_description.rb +4 -0
  57. data/lib/rubocop/cop/rspec/repeated_include_example.rb +3 -0
  58. data/lib/rubocop/cop/rspec/return_from_stub.rb +5 -0
  59. data/lib/rubocop/cop/rspec/shared_context.rb +4 -0
  60. data/lib/rubocop/cop/rspec/shared_examples.rb +1 -0
  61. data/lib/rubocop/cop/rspec/single_argument_message_chain.rb +2 -0
  62. data/lib/rubocop/cop/rspec/stubbed_mock.rb +1 -0
  63. data/lib/rubocop/cop/rspec/subject_stub.rb +1 -0
  64. data/lib/rubocop/cop/rspec/unspecified_exception.rb +1 -0
  65. data/lib/rubocop/cop/rspec/verified_doubles.rb +1 -0
  66. data/lib/rubocop/cop/rspec/void_expect.rb +2 -0
  67. data/lib/rubocop/cop/rspec/yield.rb +3 -0
  68. data/lib/rubocop/rspec/example.rb +5 -0
  69. data/lib/rubocop/rspec/hook.rb +1 -0
  70. data/lib/rubocop/rspec/language.rb +10 -0
  71. data/lib/rubocop/rspec/version.rb +1 -1
  72. metadata +6 -6
@@ -50,13 +50,16 @@ module RuboCop
50
50
  MSG = 'Repeated include of shared_examples %<name>s ' \
51
51
  'on line(s) %<repeat>s'
52
52
 
53
+ # @!method several_include_examples?(node)
53
54
  def_node_matcher :several_include_examples?, <<-PATTERN
54
55
  (begin <#include_examples? #include_examples? ...>)
55
56
  PATTERN
56
57
 
58
+ # @!method include_examples?(node)
57
59
  def_node_matcher :include_examples?,
58
60
  send_pattern('#Includes.examples')
59
61
 
62
+ # @!method shared_examples_name(node)
60
63
  def_node_matcher :shared_examples_name, <<-PATTERN
61
64
  (send _ #Includes.examples $_ ...)
62
65
  PATTERN
@@ -41,8 +41,13 @@ module RuboCop
41
41
  MSG_BLOCK = 'Use block for static values.'
42
42
  RESTRICT_ON_SEND = %i[and_return].freeze
43
43
 
44
+ # @!method contains_stub?(node)
44
45
  def_node_search :contains_stub?, '(send nil? :receive (...))'
46
+
47
+ # @!method stub_with_block?(node)
45
48
  def_node_matcher :stub_with_block?, '(block #contains_stub? ...)'
49
+
50
+ # @!method and_return_value(node)
46
51
  def_node_search :and_return_value, <<-PATTERN
47
52
  $(send _ :and_return $(...))
48
53
  PATTERN
@@ -56,9 +56,11 @@ module RuboCop
56
56
  MSG_EXAMPLES = "Use `shared_examples` when you don't define context."
57
57
  MSG_CONTEXT = "Use `shared_context` when you don't define examples."
58
58
 
59
+ # @!method examples?(node)
59
60
  def_node_search :examples?,
60
61
  send_pattern('{#Includes.examples #Examples.all}')
61
62
 
63
+ # @!method context?(node)
62
64
  def_node_search :context?, <<-PATTERN
63
65
  (
64
66
  send #rspec? {
@@ -70,8 +72,10 @@ module RuboCop
70
72
  )
71
73
  PATTERN
72
74
 
75
+ # @!method shared_context(node)
73
76
  def_node_matcher :shared_context,
74
77
  block_pattern('#SharedGroups.context')
78
+ # @!method shared_example(node)
75
79
  def_node_matcher :shared_example,
76
80
  block_pattern('#SharedGroups.examples')
77
81
 
@@ -23,6 +23,7 @@ module RuboCop
23
23
  class SharedExamples < Base
24
24
  extend AutoCorrector
25
25
 
26
+ # @!method shared_examples(node)
26
27
  def_node_matcher :shared_examples,
27
28
  send_pattern(
28
29
  '{#SharedGroups.all #Includes.all}'
@@ -23,10 +23,12 @@ module RuboCop
23
23
  '`%<called>s` with a single argument.'
24
24
  RESTRICT_ON_SEND = %i[receive_message_chain stub_chain].freeze
25
25
 
26
+ # @!method message_chain(node)
26
27
  def_node_matcher :message_chain, <<-PATTERN
27
28
  (send _ {:receive_message_chain :stub_chain} $_)
28
29
  PATTERN
29
30
 
31
+ # @!method single_key_hash?(node)
30
32
  def_node_matcher :single_key_hash?, '(hash pair)'
31
33
 
32
34
  def on_send(node)
@@ -39,6 +39,7 @@ module RuboCop
39
39
  }
40
40
  PATTERN
41
41
 
42
+ # @!method configured_response?(node)
42
43
  def_node_matcher :configured_response?, <<~PATTERN
43
44
  { :and_return :and_raise :and_throw :and_yield
44
45
  :and_call_original :and_wrap_original }
@@ -81,6 +81,7 @@ module RuboCop
81
81
  )
82
82
  PATTERN
83
83
 
84
+ # @!method message_expectation_matcher?(node)
84
85
  def_node_search :message_expectation_matcher?, <<-PATTERN
85
86
  (send nil? {
86
87
  :receive :receive_messages :receive_message_chain :have_received
@@ -34,6 +34,7 @@ module RuboCop
34
34
  MSG = 'Specify the exception being captured'
35
35
  RESTRICT_ON_SEND = %i[to].freeze
36
36
 
37
+ # @!method empty_raise_error_or_exception(node)
37
38
  def_node_matcher :empty_raise_error_or_exception, <<-PATTERN
38
39
  (send
39
40
  (block
@@ -26,6 +26,7 @@ module RuboCop
26
26
  MSG = 'Prefer using verifying doubles over normal doubles.'
27
27
  RESTRICT_ON_SEND = %i[double spy].freeze
28
28
 
29
+ # @!method unverified_double(node)
29
30
  def_node_matcher :unverified_double, <<-PATTERN
30
31
  {(send nil? {:double :spy} $...)}
31
32
  PATTERN
@@ -16,10 +16,12 @@ module RuboCop
16
16
  'Chain the methods or remove it.'
17
17
  RESTRICT_ON_SEND = %i[expect].freeze
18
18
 
19
+ # @!method expect?(node)
19
20
  def_node_matcher :expect?, <<-PATTERN
20
21
  (send nil? :expect ...)
21
22
  PATTERN
22
23
 
24
+ # @!method expect_block?(node)
23
25
  def_node_matcher :expect_block?, <<-PATTERN
24
26
  (block #expect? (args) _body)
25
27
  PATTERN
@@ -17,10 +17,13 @@ module RuboCop
17
17
 
18
18
  MSG = 'Use `.and_yield`.'
19
19
 
20
+ # @!method method_on_stub?(node)
20
21
  def_node_search :method_on_stub?, '(send nil? :receive ...)'
21
22
 
23
+ # @!method block_arg(node)
22
24
  def_node_matcher :block_arg, '(args (blockarg $_))'
23
25
 
26
+ # @!method block_call?(node)
24
27
  def_node_matcher :block_call?, '(send (lvar %) :call ...)'
25
28
 
26
29
  def on_block(node)
@@ -4,8 +4,13 @@ module RuboCop
4
4
  module RSpec
5
5
  # Wrapper for RSpec examples
6
6
  class Example < Concept
7
+ # @!method extract_doc_string(node)
7
8
  def_node_matcher :extract_doc_string, '(send _ _ $_ ...)'
9
+
10
+ # @!method extract_metadata(node)
8
11
  def_node_matcher :extract_metadata, '(send _ _ _ $...)'
12
+
13
+ # @!method extract_implementation(node)
9
14
  def_node_matcher :extract_implementation, '(block send args $_)'
10
15
 
11
16
  def doc_string
@@ -4,6 +4,7 @@ module RuboCop
4
4
  module RSpec
5
5
  # Wrapper for RSpec hook
6
6
  class Hook < Concept
7
+ # @!method extract_metadata(node)
7
8
  def_node_matcher :extract_metadata, <<~PATTERN
8
9
  (block
9
10
  (send _ _ #valid_scope? ? $...) ...
@@ -19,23 +19,31 @@ module RuboCop
19
19
  attr_accessor :config
20
20
  end
21
21
 
22
+ # @!method rspec?(node)
22
23
  def_node_matcher :rspec?, '{(const {nil? cbase} :RSpec) nil?}'
23
24
 
25
+ # @!method example_group?(node)
24
26
  def_node_matcher :example_group?, block_pattern('#ExampleGroups.all')
25
27
 
28
+ # @!method shared_group?(node)
26
29
  def_node_matcher :shared_group?, block_pattern('#SharedGroups.all')
27
30
 
31
+ # @!method spec_group?(node)
28
32
  def_node_matcher :spec_group?,
29
33
  block_pattern('{#SharedGroups.all #ExampleGroups.all}')
30
34
 
35
+ # @!method example_group_with_body?(node)
31
36
  def_node_matcher :example_group_with_body?, <<-PATTERN
32
37
  (block #{send_pattern('#ExampleGroups.all')} args !nil?)
33
38
  PATTERN
34
39
 
40
+ # @!method example?(node)
35
41
  def_node_matcher :example?, block_pattern('#Examples.all')
36
42
 
43
+ # @!method hook?(node)
37
44
  def_node_matcher :hook?, block_pattern('#Hooks.all')
38
45
 
46
+ # @!method let?(node)
39
47
  def_node_matcher :let?, <<-PATTERN
40
48
  {
41
49
  #{block_pattern('#Helpers.all')}
@@ -43,6 +51,7 @@ module RuboCop
43
51
  }
44
52
  PATTERN
45
53
 
54
+ # @!method include?(node)
46
55
  def_node_matcher :include?, <<-PATTERN
47
56
  {
48
57
  #{send_pattern('#Includes.all')}
@@ -50,6 +59,7 @@ module RuboCop
50
59
  }
51
60
  PATTERN
52
61
 
62
+ # @!method subject?(node)
53
63
  def_node_matcher :subject?, block_pattern('#Subjects.all')
54
64
 
55
65
  module ExampleGroups # :nodoc:
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module RSpec
5
5
  # Version information for the RSpec RuboCop plugin.
6
6
  module Version
7
- STRING = '2.2.0'
7
+ STRING = '2.3.0'
8
8
  end
9
9
  end
10
10
  end
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.2.0
4
+ version: 2.3.0
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: 2021-02-02 00:00:00.000000000 Z
13
+ date: 2021-04-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -251,11 +251,11 @@ files:
251
251
  - lib/rubocop/rspec/node.rb
252
252
  - lib/rubocop/rspec/version.rb
253
253
  - lib/rubocop/rspec/wording.rb
254
- homepage: https://github.com/rubocop-hq/rubocop-rspec
254
+ homepage: https://github.com/rubocop/rubocop-rspec
255
255
  licenses:
256
256
  - MIT
257
257
  metadata:
258
- changelog_uri: https://github.com/rubocop-hq/rubocop-rspec/blob/master/CHANGELOG.md
258
+ changelog_uri: https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md
259
259
  documentation_uri: https://docs.rubocop.org/rubocop-rspec/
260
260
  post_install_message:
261
261
  rdoc_options: []
@@ -265,14 +265,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
265
265
  requirements:
266
266
  - - ">="
267
267
  - !ruby/object:Gem::Version
268
- version: 2.4.0
268
+ version: 2.5.0
269
269
  required_rubygems_version: !ruby/object:Gem::Requirement
270
270
  requirements:
271
271
  - - ">="
272
272
  - !ruby/object:Gem::Version
273
273
  version: '0'
274
274
  requirements: []
275
- rubygems_version: 3.2.2
275
+ rubygems_version: 3.2.16
276
276
  signing_key:
277
277
  specification_version: 4
278
278
  summary: Code style checking for RSpec files