rubocop-rspec 2.1.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -0
  3. data/README.md +2 -2
  4. data/config/default.yml +36 -1
  5. data/lib/rubocop/cop/rspec/any_instance.rb +6 -10
  6. data/lib/rubocop/cop/rspec/around_block.rb +2 -0
  7. data/lib/rubocop/cop/rspec/be.rb +1 -0
  8. data/lib/rubocop/cop/rspec/be_eql.rb +2 -0
  9. data/lib/rubocop/cop/rspec/before_after_all.rb +3 -0
  10. data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +5 -0
  11. data/lib/rubocop/cop/rspec/capybara/feature_methods.rb +3 -0
  12. data/lib/rubocop/cop/rspec/capybara/visibility_matcher.rb +4 -0
  13. data/lib/rubocop/cop/rspec/context_method.rb +1 -0
  14. data/lib/rubocop/cop/rspec/context_wording.rb +7 -1
  15. data/lib/rubocop/cop/rspec/describe_class.rb +3 -0
  16. data/lib/rubocop/cop/rspec/describe_method.rb +1 -0
  17. data/lib/rubocop/cop/rspec/describe_symbol.rb +2 -0
  18. data/lib/rubocop/cop/rspec/described_class.rb +6 -1
  19. data/lib/rubocop/cop/rspec/described_class_module_wrapping.rb +2 -1
  20. data/lib/rubocop/cop/rspec/dialect.rb +1 -0
  21. data/lib/rubocop/cop/rspec/empty_hook.rb +5 -1
  22. data/lib/rubocop/cop/rspec/example_length.rb +26 -12
  23. data/lib/rubocop/cop/rspec/example_without_description.rb +1 -0
  24. data/lib/rubocop/cop/rspec/example_wording.rb +1 -0
  25. data/lib/rubocop/cop/rspec/excessive_docstring_spacing.rb +96 -0
  26. data/lib/rubocop/cop/rspec/expect_actual.rb +1 -0
  27. data/lib/rubocop/cop/rspec/expect_change.rb +6 -3
  28. data/lib/rubocop/cop/rspec/expect_in_hook.rb +1 -0
  29. data/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb +3 -0
  30. data/lib/rubocop/cop/rspec/factory_bot/create_list.rb +4 -0
  31. data/lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb +2 -0
  32. data/lib/rubocop/cop/rspec/file_path.rb +13 -9
  33. data/lib/rubocop/cop/rspec/focus.rb +3 -0
  34. data/lib/rubocop/cop/rspec/hook_argument.rb +3 -1
  35. data/lib/rubocop/cop/rspec/hooks_before_examples.rb +1 -0
  36. data/lib/rubocop/cop/rspec/identical_equality_assertion.rb +38 -0
  37. data/lib/rubocop/cop/rspec/implicit_block_expectation.rb +4 -0
  38. data/lib/rubocop/cop/rspec/implicit_expect.rb +1 -0
  39. data/lib/rubocop/cop/rspec/implicit_subject.rb +19 -1
  40. data/lib/rubocop/cop/rspec/instance_spy.rb +2 -0
  41. data/lib/rubocop/cop/rspec/instance_variable.rb +4 -0
  42. data/lib/rubocop/cop/rspec/it_behaves_like.rb +2 -0
  43. data/lib/rubocop/cop/rspec/iterated_expectation.rb +4 -0
  44. data/lib/rubocop/cop/rspec/let_before_examples.rb +1 -0
  45. data/lib/rubocop/cop/rspec/let_setup.rb +3 -0
  46. data/lib/rubocop/cop/rspec/message_chain.rb +4 -10
  47. data/lib/rubocop/cop/rspec/message_expectation.rb +3 -0
  48. data/lib/rubocop/cop/rspec/message_spies.rb +2 -0
  49. data/lib/rubocop/cop/rspec/mixin/comments_help.rb +38 -0
  50. data/lib/rubocop/cop/rspec/mixin/variable.rb +1 -0
  51. data/lib/rubocop/cop/rspec/multiple_expectations.rb +3 -0
  52. data/lib/rubocop/cop/rspec/named_subject.rb +3 -0
  53. data/lib/rubocop/cop/rspec/nested_groups.rb +1 -1
  54. data/lib/rubocop/cop/rspec/not_to_not.rb +2 -0
  55. data/lib/rubocop/cop/rspec/overwriting_setup.rb +2 -0
  56. data/lib/rubocop/cop/rspec/pending.rb +4 -0
  57. data/lib/rubocop/cop/rspec/predicate_matcher.rb +5 -0
  58. data/lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb +44 -0
  59. data/lib/rubocop/cop/rspec/rails/http_status.rb +2 -0
  60. data/lib/rubocop/cop/rspec/receive_counts.rb +4 -0
  61. data/lib/rubocop/cop/rspec/receive_never.rb +2 -0
  62. data/lib/rubocop/cop/rspec/repeated_example_group_body.rb +8 -1
  63. data/lib/rubocop/cop/rspec/repeated_example_group_description.rb +4 -0
  64. data/lib/rubocop/cop/rspec/repeated_include_example.rb +3 -0
  65. data/lib/rubocop/cop/rspec/return_from_stub.rb +6 -0
  66. data/lib/rubocop/cop/rspec/shared_context.rb +4 -0
  67. data/lib/rubocop/cop/rspec/shared_examples.rb +1 -0
  68. data/lib/rubocop/cop/rspec/single_argument_message_chain.rb +3 -0
  69. data/lib/rubocop/cop/rspec/stubbed_mock.rb +1 -0
  70. data/lib/rubocop/cop/rspec/subject_declaration.rb +47 -0
  71. data/lib/rubocop/cop/rspec/subject_stub.rb +1 -0
  72. data/lib/rubocop/cop/rspec/unspecified_exception.rb +2 -0
  73. data/lib/rubocop/cop/rspec/verified_doubles.rb +2 -0
  74. data/lib/rubocop/cop/rspec/void_expect.rb +3 -0
  75. data/lib/rubocop/cop/rspec/yield.rb +3 -0
  76. data/lib/rubocop/cop/rspec_cops.rb +4 -0
  77. data/lib/rubocop/rspec/corrector/move_node.rb +6 -9
  78. data/lib/rubocop/rspec/example.rb +5 -0
  79. data/lib/rubocop/rspec/hook.rb +1 -0
  80. data/lib/rubocop/rspec/language.rb +10 -0
  81. data/lib/rubocop/rspec/version.rb +1 -1
  82. data/lib/rubocop-rspec.rb +1 -0
  83. metadata +30 -25
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module RSpec
6
+ module Rails
7
+ # Checks that tests use RSpec `before` hook over Rails `setup` method.
8
+ #
9
+ # @example
10
+ #
11
+ # # bad
12
+ # setup do
13
+ # allow(foo).to receive(:bar)
14
+ # end
15
+ #
16
+ # # good
17
+ # before do
18
+ # allow(foo).to receive(:bar)
19
+ # end
20
+ #
21
+ class AvoidSetupHook < Base
22
+ extend AutoCorrector
23
+
24
+ MSG = 'Use `before` instead of `setup`.'
25
+
26
+ # @!method setup_call(node)
27
+ def_node_matcher :setup_call, <<-PATTERN
28
+ (block
29
+ $(send nil? :setup)
30
+ (args) _)
31
+ PATTERN
32
+
33
+ def on_block(node)
34
+ setup_call(node) do |setup|
35
+ add_offense(node) do |corrector|
36
+ corrector.replace setup, 'before'
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -33,7 +33,9 @@ module RuboCop
33
33
  class HttpStatus < Base
34
34
  extend AutoCorrector
35
35
  include ConfigurableEnforcedStyle
36
+ RESTRICT_ON_SEND = %i[have_http_status].freeze
36
37
 
38
+ # @!method http_status(node)
37
39
  def_node_matcher :http_status, <<-PATTERN
38
40
  (send nil? :have_http_status ${int sym})
39
41
  PATTERN
@@ -28,10 +28,14 @@ module RuboCop
28
28
 
29
29
  MSG = 'Use `%<alternative>s` instead of `%<original>s`.'
30
30
 
31
+ RESTRICT_ON_SEND = %i[times].freeze
32
+
33
+ # @!method receive_counts(node)
31
34
  def_node_matcher :receive_counts, <<-PATTERN
32
35
  (send $(send _ {:exactly :at_least :at_most} (int {1 2})) :times)
33
36
  PATTERN
34
37
 
38
+ # @!method stub?(node)
35
39
  def_node_search :stub?, '(send nil? :receive ...)'
36
40
 
37
41
  def on_send(node)
@@ -16,7 +16,9 @@ module RuboCop
16
16
  class ReceiveNever < Base
17
17
  extend AutoCorrector
18
18
  MSG = 'Use `not_to receive` instead of `never`.'
19
+ RESTRICT_ON_SEND = %i[never].freeze
19
20
 
21
+ # @!method method_on_stub?(node)
20
22
  def_node_search :method_on_stub?, '(send nil? :receive ...)'
21
23
 
22
24
  def on_send(node)
@@ -46,16 +46,23 @@ module RuboCop
46
46
  class RepeatedExampleGroupBody < Base
47
47
  MSG = 'Repeated %<group>s block body on line(s) %<loc>s'
48
48
 
49
+ # @!method several_example_groups?(node)
49
50
  def_node_matcher :several_example_groups?, <<-PATTERN
50
51
  (begin <#example_group_with_body? #example_group_with_body? ...>)
51
52
  PATTERN
52
53
 
54
+ # @!method metadata(node)
53
55
  def_node_matcher :metadata, '(block (send _ _ _ $...) ...)'
56
+
57
+ # @!method body(node)
54
58
  def_node_matcher :body, '(block _ args $...)'
59
+
60
+ # @!method const_arg(node)
55
61
  def_node_matcher :const_arg, '(block (send _ _ $const ...) ...)'
56
62
 
63
+ # @!method skip_or_pending?(node)
57
64
  def_node_matcher :skip_or_pending?, <<-PATTERN
58
- (block <(send nil? {:skip :pending}) ...>)
65
+ (block <(send nil? {:skip :pending} ...) ...>)
59
66
  PATTERN
60
67
 
61
68
  def on_begin(node)
@@ -46,18 +46,22 @@ module RuboCop
46
46
  class RepeatedExampleGroupDescription < Base
47
47
  MSG = 'Repeated %<group>s block description on line(s) %<loc>s'
48
48
 
49
+ # @!method several_example_groups?(node)
49
50
  def_node_matcher :several_example_groups?, <<-PATTERN
50
51
  (begin <#example_group? #example_group? ...>)
51
52
  PATTERN
52
53
 
54
+ # @!method doc_string_and_metadata(node)
53
55
  def_node_matcher :doc_string_and_metadata, <<-PATTERN
54
56
  (block (send _ _ $_ $...) ...)
55
57
  PATTERN
56
58
 
59
+ # @!method skip_or_pending?(node)
57
60
  def_node_matcher :skip_or_pending?, <<-PATTERN
58
61
  (block <(send nil? {:skip :pending}) ...>)
59
62
  PATTERN
60
63
 
64
+ # @!method empty_description?(node)
61
65
  def_node_matcher :empty_description?, '(block (send _ _) ...)'
62
66
 
63
67
  def on_begin(node)
@@ -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
@@ -39,9 +39,15 @@ module RuboCop
39
39
 
40
40
  MSG_AND_RETURN = 'Use `and_return` for static values.'
41
41
  MSG_BLOCK = 'Use block for static values.'
42
+ RESTRICT_ON_SEND = %i[and_return].freeze
42
43
 
44
+ # @!method contains_stub?(node)
43
45
  def_node_search :contains_stub?, '(send nil? :receive (...))'
46
+
47
+ # @!method stub_with_block?(node)
44
48
  def_node_matcher :stub_with_block?, '(block #contains_stub? ...)'
49
+
50
+ # @!method and_return_value(node)
45
51
  def_node_search :and_return_value, <<-PATTERN
46
52
  $(send _ :and_return $(...))
47
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}'
@@ -21,11 +21,14 @@ module RuboCop
21
21
 
22
22
  MSG = 'Use `%<recommended>s` instead of calling ' \
23
23
  '`%<called>s` with a single argument.'
24
+ RESTRICT_ON_SEND = %i[receive_message_chain stub_chain].freeze
24
25
 
26
+ # @!method message_chain(node)
25
27
  def_node_matcher :message_chain, <<-PATTERN
26
28
  (send _ {:receive_message_chain :stub_chain} $_)
27
29
  PATTERN
28
30
 
31
+ # @!method single_key_hash?(node)
29
32
  def_node_matcher :single_key_hash?, '(hash pair)'
30
33
 
31
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 }
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module RSpec
6
+ # Ensure that subject is defined using subject helper.
7
+ #
8
+ # @example
9
+ #
10
+ # # bad
11
+ # let(:subject) { foo }
12
+ # let!(:subject) { foo }
13
+ # subject(:subject) { foo }
14
+ # subject!(:subject) { foo }
15
+ #
16
+ # # bad
17
+ # block = -> {}
18
+ # let(:subject, &block)
19
+ #
20
+ # # good
21
+ # subject(:test_subject) { foo }
22
+ #
23
+ class SubjectDeclaration < Base
24
+ MSG_LET = 'Use subject explicitly rather than using let'
25
+ MSG_REDUNDANT = 'Ambiguous declaration of subject'
26
+
27
+ # @!method offensive_subject_declaration?(node)
28
+ def_node_matcher :offensive_subject_declaration?, <<~PATTERN
29
+ (send nil? ${#Subjects.all #Helpers.all} {(sym :subject) (str "subject")} ...)
30
+ PATTERN
31
+
32
+ def on_send(node)
33
+ offense = offensive_subject_declaration?(node)
34
+ return unless offense
35
+
36
+ add_offense(node, message: message_for(offense))
37
+ end
38
+
39
+ private
40
+
41
+ def message_for(offense)
42
+ Helpers.all(offense) ? MSG_LET : MSG_REDUNDANT
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -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
@@ -32,7 +32,9 @@ module RuboCop
32
32
  # expect { do_something }.not_to raise_error
33
33
  class UnspecifiedException < Base
34
34
  MSG = 'Specify the exception being captured'
35
+ RESTRICT_ON_SEND = %i[to].freeze
35
36
 
37
+ # @!method empty_raise_error_or_exception(node)
36
38
  def_node_matcher :empty_raise_error_or_exception, <<-PATTERN
37
39
  (send
38
40
  (block
@@ -24,7 +24,9 @@ module RuboCop
24
24
  # end
25
25
  class VerifiedDoubles < Base
26
26
  MSG = 'Prefer using verifying doubles over normal doubles.'
27
+ RESTRICT_ON_SEND = %i[double spy].freeze
27
28
 
29
+ # @!method unverified_double(node)
28
30
  def_node_matcher :unverified_double, <<-PATTERN
29
31
  {(send nil? {:double :spy} $...)}
30
32
  PATTERN
@@ -14,11 +14,14 @@ module RuboCop
14
14
  class VoidExpect < Base
15
15
  MSG = 'Do not use `expect()` without `.to` or `.not_to`. ' \
16
16
  'Chain the methods or remove it.'
17
+ RESTRICT_ON_SEND = %i[expect].freeze
17
18
 
19
+ # @!method expect?(node)
18
20
  def_node_matcher :expect?, <<-PATTERN
19
21
  (send nil? :expect ...)
20
22
  PATTERN
21
23
 
24
+ # @!method expect_block?(node)
22
25
  def_node_matcher :expect_block?, <<-PATTERN
23
26
  (block #expect? (args) _body)
24
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)
@@ -8,6 +8,7 @@ require_relative 'rspec/factory_bot/attribute_defined_statically'
8
8
  require_relative 'rspec/factory_bot/create_list'
9
9
  require_relative 'rspec/factory_bot/factory_class_name'
10
10
 
11
+ require_relative 'rspec/rails/avoid_setup_hook'
11
12
  begin
12
13
  require_relative 'rspec/rails/http_status'
13
14
  rescue LoadError
@@ -39,6 +40,7 @@ require_relative 'rspec/empty_line_after_subject'
39
40
  require_relative 'rspec/example_length'
40
41
  require_relative 'rspec/example_without_description'
41
42
  require_relative 'rspec/example_wording'
43
+ require_relative 'rspec/excessive_docstring_spacing'
42
44
  require_relative 'rspec/expect_actual'
43
45
  require_relative 'rspec/expect_change'
44
46
  require_relative 'rspec/expect_in_hook'
@@ -47,6 +49,7 @@ require_relative 'rspec/file_path'
47
49
  require_relative 'rspec/focus'
48
50
  require_relative 'rspec/hook_argument'
49
51
  require_relative 'rspec/hooks_before_examples'
52
+ require_relative 'rspec/identical_equality_assertion'
50
53
  require_relative 'rspec/implicit_block_expectation'
51
54
  require_relative 'rspec/implicit_expect'
52
55
  require_relative 'rspec/implicit_subject'
@@ -86,6 +89,7 @@ require_relative 'rspec/shared_context'
86
89
  require_relative 'rspec/shared_examples'
87
90
  require_relative 'rspec/single_argument_message_chain'
88
91
  require_relative 'rspec/stubbed_mock'
92
+ require_relative 'rspec/subject_declaration'
89
93
  require_relative 'rspec/subject_stub'
90
94
  require_relative 'rspec/unspecified_exception'
91
95
  require_relative 'rspec/variable_definition'
@@ -6,6 +6,7 @@ module RuboCop
6
6
  # Helper methods to move a node
7
7
  class MoveNode
8
8
  include RuboCop::Cop::RangeHelp
9
+ include RuboCop::Cop::RSpec::CommentsHelp
9
10
  include RuboCop::Cop::RSpec::FinalEndLocation
10
11
 
11
12
  attr_reader :original, :corrector, :processed_source
@@ -17,20 +18,16 @@ module RuboCop
17
18
  end
18
19
 
19
20
  def move_before(other)
20
- position = other.loc.expression
21
- indent = ' ' * other.loc.column
22
- newline_indent = "\n#{indent}"
21
+ position = start_line_position(other)
23
22
 
24
- corrector.insert_before(position, source(original) + newline_indent)
23
+ corrector.insert_before(position, "#{source(original)}\n")
25
24
  corrector.remove(node_range_with_surrounding_space(original))
26
25
  end
27
26
 
28
27
  def move_after(other)
29
- position = final_end_location(other)
30
- indent = ' ' * other.loc.column
31
- newline_indent = "\n#{indent}"
28
+ position = end_line_position(other)
32
29
 
33
- corrector.insert_after(position, newline_indent + source(original))
30
+ corrector.insert_after(position, "\n#{source(original)}")
34
31
  corrector.remove(node_range_with_surrounding_space(original))
35
32
  end
36
33
 
@@ -41,7 +38,7 @@ module RuboCop
41
38
  end
42
39
 
43
40
  def node_range(node)
44
- node.loc.expression.with(end_pos: final_end_location(node).end_pos)
41
+ source_range_with_comment(node)
45
42
  end
46
43
 
47
44
  def node_range_with_surrounding_space(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.1.0'
7
+ STRING = '2.5.0'
8
8
  end
9
9
  end
10
10
  end
data/lib/rubocop-rspec.rb CHANGED
@@ -15,6 +15,7 @@ require_relative 'rubocop/rspec/language'
15
15
  require_relative 'rubocop/cop/rspec/mixin/top_level_group'
16
16
  require_relative 'rubocop/cop/rspec/mixin/variable'
17
17
  require_relative 'rubocop/cop/rspec/mixin/final_end_location'
18
+ require_relative 'rubocop/cop/rspec/mixin/comments_help'
18
19
  require_relative 'rubocop/cop/rspec/mixin/empty_line_separation'
19
20
 
20
21
  require_relative 'rubocop/rspec/concept'
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Backus
8
8
  - Ian MacLeod
9
9
  - Nils Gemeinhardt
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-12-17 00:00:00.000000000 Z
13
+ date: 2021-09-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -18,28 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '1.0'
21
+ version: '1.19'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: '1.0'
29
- - !ruby/object:Gem::Dependency
30
- name: rubocop-ast
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
35
- version: 1.1.0
36
- type: :runtime
37
- prerelease: false
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 1.1.0
28
+ version: '1.19'
43
29
  - !ruby/object:Gem::Dependency
44
30
  name: rack
45
31
  requirement: !ruby/object:Gem::Requirement
@@ -96,6 +82,20 @@ dependencies:
96
82
  - - "~>"
97
83
  - !ruby/object:Gem::Version
98
84
  version: '1.7'
85
+ - !ruby/object:Gem::Dependency
86
+ name: rubocop-rake
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '0.6'
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: '0.6'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: simplecov
101
101
  requirement: !ruby/object:Gem::Requirement
@@ -172,6 +172,7 @@ files:
172
172
  - lib/rubocop/cop/rspec/example_length.rb
173
173
  - lib/rubocop/cop/rspec/example_without_description.rb
174
174
  - lib/rubocop/cop/rspec/example_wording.rb
175
+ - lib/rubocop/cop/rspec/excessive_docstring_spacing.rb
175
176
  - lib/rubocop/cop/rspec/expect_actual.rb
176
177
  - lib/rubocop/cop/rspec/expect_change.rb
177
178
  - lib/rubocop/cop/rspec/expect_in_hook.rb
@@ -183,6 +184,7 @@ files:
183
184
  - lib/rubocop/cop/rspec/focus.rb
184
185
  - lib/rubocop/cop/rspec/hook_argument.rb
185
186
  - lib/rubocop/cop/rspec/hooks_before_examples.rb
187
+ - lib/rubocop/cop/rspec/identical_equality_assertion.rb
186
188
  - lib/rubocop/cop/rspec/implicit_block_expectation.rb
187
189
  - lib/rubocop/cop/rspec/implicit_expect.rb
188
190
  - lib/rubocop/cop/rspec/implicit_subject.rb
@@ -198,6 +200,7 @@ files:
198
200
  - lib/rubocop/cop/rspec/message_expectation.rb
199
201
  - lib/rubocop/cop/rspec/message_spies.rb
200
202
  - lib/rubocop/cop/rspec/missing_example_group_argument.rb
203
+ - lib/rubocop/cop/rspec/mixin/comments_help.rb
201
204
  - lib/rubocop/cop/rspec/mixin/empty_line_separation.rb
202
205
  - lib/rubocop/cop/rspec/mixin/final_end_location.rb
203
206
  - lib/rubocop/cop/rspec/mixin/top_level_group.rb
@@ -212,6 +215,7 @@ files:
212
215
  - lib/rubocop/cop/rspec/overwriting_setup.rb
213
216
  - lib/rubocop/cop/rspec/pending.rb
214
217
  - lib/rubocop/cop/rspec/predicate_matcher.rb
218
+ - lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb
215
219
  - lib/rubocop/cop/rspec/rails/http_status.rb
216
220
  - lib/rubocop/cop/rspec/receive_counts.rb
217
221
  - lib/rubocop/cop/rspec/receive_never.rb
@@ -227,6 +231,7 @@ files:
227
231
  - lib/rubocop/cop/rspec/shared_examples.rb
228
232
  - lib/rubocop/cop/rspec/single_argument_message_chain.rb
229
233
  - lib/rubocop/cop/rspec/stubbed_mock.rb
234
+ - lib/rubocop/cop/rspec/subject_declaration.rb
230
235
  - lib/rubocop/cop/rspec/subject_stub.rb
231
236
  - lib/rubocop/cop/rspec/unspecified_exception.rb
232
237
  - lib/rubocop/cop/rspec/variable_definition.rb
@@ -250,13 +255,13 @@ files:
250
255
  - lib/rubocop/rspec/node.rb
251
256
  - lib/rubocop/rspec/version.rb
252
257
  - lib/rubocop/rspec/wording.rb
253
- homepage: https://github.com/rubocop-hq/rubocop-rspec
258
+ homepage: https://github.com/rubocop/rubocop-rspec
254
259
  licenses:
255
260
  - MIT
256
261
  metadata:
257
- changelog_uri: https://github.com/rubocop-hq/rubocop-rspec/blob/master/CHANGELOG.md
262
+ changelog_uri: https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md
258
263
  documentation_uri: https://docs.rubocop.org/rubocop-rspec/
259
- post_install_message:
264
+ post_install_message:
260
265
  rdoc_options: []
261
266
  require_paths:
262
267
  - lib
@@ -264,15 +269,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
264
269
  requirements:
265
270
  - - ">="
266
271
  - !ruby/object:Gem::Version
267
- version: 2.4.0
272
+ version: 2.5.0
268
273
  required_rubygems_version: !ruby/object:Gem::Requirement
269
274
  requirements:
270
275
  - - ">="
271
276
  - !ruby/object:Gem::Version
272
277
  version: '0'
273
278
  requirements: []
274
- rubygems_version: 3.2.2
275
- signing_key:
279
+ rubygems_version: 3.1.2
280
+ signing_key:
276
281
  specification_version: 4
277
282
  summary: Code style checking for RSpec files
278
283
  test_files: []