rubocop-rspec 2.12.0 → 2.13.1

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 (103) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +118 -86
  3. data/config/default.yml +44 -6
  4. data/config/obsoletion.yml +14 -0
  5. data/lib/rubocop/cop/rspec/align_left_let_brace.rb +8 -9
  6. data/lib/rubocop/cop/rspec/align_right_let_brace.rb +8 -9
  7. data/lib/rubocop/cop/rspec/any_instance.rb +1 -0
  8. data/lib/rubocop/cop/rspec/around_block.rb +26 -3
  9. data/lib/rubocop/cop/rspec/be.rb +0 -1
  10. data/lib/rubocop/cop/rspec/be_eq.rb +0 -1
  11. data/lib/rubocop/cop/rspec/be_eql.rb +0 -1
  12. data/lib/rubocop/cop/rspec/before_after_all.rb +1 -0
  13. data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +9 -3
  14. data/lib/rubocop/cop/rspec/capybara/feature_methods.rb +2 -1
  15. data/lib/rubocop/cop/rspec/capybara/specific_finders.rb +86 -0
  16. data/lib/rubocop/cop/rspec/capybara/specific_matcher.rb +91 -10
  17. data/lib/rubocop/cop/rspec/capybara/visibility_matcher.rb +0 -1
  18. data/lib/rubocop/cop/rspec/change_by_zero.rb +60 -5
  19. data/lib/rubocop/cop/rspec/class_check.rb +101 -0
  20. data/lib/rubocop/cop/rspec/context_method.rb +2 -1
  21. data/lib/rubocop/cop/rspec/context_wording.rb +49 -18
  22. data/lib/rubocop/cop/rspec/describe_class.rb +1 -1
  23. data/lib/rubocop/cop/rspec/describe_method.rb +1 -0
  24. data/lib/rubocop/cop/rspec/described_class.rb +4 -14
  25. data/lib/rubocop/cop/rspec/dialect.rb +1 -0
  26. data/lib/rubocop/cop/rspec/empty_example_group.rb +19 -4
  27. data/lib/rubocop/cop/rspec/empty_hook.rb +2 -1
  28. data/lib/rubocop/cop/rspec/empty_line_after_example.rb +4 -9
  29. data/lib/rubocop/cop/rspec/empty_line_after_example_group.rb +1 -1
  30. data/lib/rubocop/cop/rspec/empty_line_after_final_let.rb +2 -1
  31. data/lib/rubocop/cop/rspec/empty_line_after_hook.rb +32 -2
  32. data/lib/rubocop/cop/rspec/empty_line_after_subject.rb +2 -1
  33. data/lib/rubocop/cop/rspec/example_length.rb +2 -1
  34. data/lib/rubocop/cop/rspec/example_without_description.rb +2 -1
  35. data/lib/rubocop/cop/rspec/example_wording.rb +2 -1
  36. data/lib/rubocop/cop/rspec/excessive_docstring_spacing.rb +1 -0
  37. data/lib/rubocop/cop/rspec/expect_actual.rb +3 -0
  38. data/lib/rubocop/cop/rspec/expect_change.rb +1 -1
  39. data/lib/rubocop/cop/rspec/expect_in_hook.rb +4 -1
  40. data/lib/rubocop/cop/rspec/expect_output.rb +1 -0
  41. data/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb +2 -1
  42. data/lib/rubocop/cop/rspec/factory_bot/create_list.rb +26 -12
  43. data/lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb +1 -0
  44. data/lib/rubocop/cop/rspec/file_path.rb +6 -3
  45. data/lib/rubocop/cop/rspec/focus.rb +18 -0
  46. data/lib/rubocop/cop/rspec/hook_argument.rb +7 -2
  47. data/lib/rubocop/cop/rspec/hooks_before_examples.rb +10 -9
  48. data/lib/rubocop/cop/rspec/identical_equality_assertion.rb +0 -1
  49. data/lib/rubocop/cop/rspec/implicit_block_expectation.rb +1 -0
  50. data/lib/rubocop/cop/rspec/implicit_expect.rb +0 -2
  51. data/lib/rubocop/cop/rspec/instance_spy.rb +1 -1
  52. data/lib/rubocop/cop/rspec/instance_variable.rb +0 -1
  53. data/lib/rubocop/cop/rspec/it_behaves_like.rb +1 -0
  54. data/lib/rubocop/cop/rspec/iterated_expectation.rb +16 -0
  55. data/lib/rubocop/cop/rspec/leading_subject.rb +15 -15
  56. data/lib/rubocop/cop/rspec/let_before_examples.rb +7 -8
  57. data/lib/rubocop/cop/rspec/let_setup.rb +4 -4
  58. data/lib/rubocop/cop/rspec/message_chain.rb +1 -1
  59. data/lib/rubocop/cop/rspec/missing_example_group_argument.rb +2 -1
  60. data/lib/rubocop/cop/rspec/mixin/css_selector.rb +99 -0
  61. data/lib/rubocop/cop/rspec/mixin/namespace.rb +23 -0
  62. data/lib/rubocop/cop/rspec/multiple_describes.rb +1 -0
  63. data/lib/rubocop/cop/rspec/multiple_expectations.rb +1 -5
  64. data/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb +1 -3
  65. data/lib/rubocop/cop/rspec/multiple_subjects.rb +17 -2
  66. data/lib/rubocop/cop/rspec/named_subject.rb +2 -1
  67. data/lib/rubocop/cop/rspec/nested_groups.rb +45 -25
  68. data/lib/rubocop/cop/rspec/no_expectation_example.rb +64 -0
  69. data/lib/rubocop/cop/rspec/not_to_not.rb +1 -2
  70. data/lib/rubocop/cop/rspec/overwriting_setup.rb +2 -1
  71. data/lib/rubocop/cop/rspec/pending.rb +1 -0
  72. data/lib/rubocop/cop/rspec/predicate_matcher.rb +2 -1
  73. data/lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb +1 -2
  74. data/lib/rubocop/cop/rspec/receive_counts.rb +14 -15
  75. data/lib/rubocop/cop/rspec/receive_never.rb +4 -5
  76. data/lib/rubocop/cop/rspec/repeated_description.rb +25 -26
  77. data/lib/rubocop/cop/rspec/repeated_example.rb +1 -1
  78. data/lib/rubocop/cop/rspec/repeated_example_group_body.rb +28 -29
  79. data/lib/rubocop/cop/rspec/repeated_example_group_description.rb +28 -29
  80. data/lib/rubocop/cop/rspec/repeated_include_example.rb +32 -33
  81. data/lib/rubocop/cop/rspec/return_from_stub.rb +1 -1
  82. data/lib/rubocop/cop/rspec/scattered_let.rb +1 -5
  83. data/lib/rubocop/cop/rspec/scattered_setup.rb +1 -1
  84. data/lib/rubocop/cop/rspec/shared_context.rb +1 -1
  85. data/lib/rubocop/cop/rspec/stubbed_mock.rb +0 -1
  86. data/lib/rubocop/cop/rspec/subject_declaration.rb +0 -1
  87. data/lib/rubocop/cop/rspec/subject_stub.rb +2 -2
  88. data/lib/rubocop/cop/rspec/unspecified_exception.rb +15 -15
  89. data/lib/rubocop/cop/rspec/variable_definition.rb +1 -0
  90. data/lib/rubocop/cop/rspec/variable_name.rb +6 -7
  91. data/lib/rubocop/cop/rspec/verified_doubles.rb +1 -0
  92. data/lib/rubocop/cop/rspec/void_expect.rb +2 -1
  93. data/lib/rubocop/cop/rspec/yield.rb +2 -1
  94. data/lib/rubocop/cop/rspec_cops.rb +3 -0
  95. data/lib/rubocop/rspec/config_formatter.rb +14 -3
  96. data/lib/rubocop/rspec/inject.rb +1 -3
  97. data/lib/rubocop/rspec/language/node_pattern.rb +4 -0
  98. data/lib/rubocop/rspec/language.rb +6 -1
  99. data/lib/rubocop/rspec/version.rb +1 -1
  100. data/lib/rubocop/rspec/wording.rb +2 -2
  101. data/lib/rubocop/rspec.rb +14 -0
  102. data/lib/rubocop-rspec.rb +3 -0
  103. metadata +11 -88
@@ -276,6 +276,7 @@ module RuboCop
276
276
  #
277
277
  # # good - the above code is rewritten to it by this cop
278
278
  # expect(foo.something?).to be_truthy
279
+ #
279
280
  class PredicateMatcher < Base
280
281
  extend AutoCorrector
281
282
  include ConfigurableEnforcedStyle
@@ -291,7 +292,7 @@ module RuboCop
291
292
  end
292
293
  end
293
294
 
294
- def on_block(node)
295
+ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
295
296
  check_explicit(node) if style == :explicit
296
297
  end
297
298
 
@@ -7,7 +7,6 @@ module RuboCop
7
7
  # Checks that tests use RSpec `before` hook over Rails `setup` method.
8
8
  #
9
9
  # @example
10
- #
11
10
  # # bad
12
11
  # setup do
13
12
  # allow(foo).to receive(:bar)
@@ -30,7 +29,7 @@ module RuboCop
30
29
  (args) _)
31
30
  PATTERN
32
31
 
33
- def on_block(node)
32
+ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
34
33
  setup_call(node) do |setup|
35
34
  add_offense(node) do |corrector|
36
35
  corrector.replace setup, 'before'
@@ -6,22 +6,21 @@ module RuboCop
6
6
  # Check for `once` and `twice` receive counts matchers usage.
7
7
  #
8
8
  # @example
9
+ # # bad
10
+ # expect(foo).to receive(:bar).exactly(1).times
11
+ # expect(foo).to receive(:bar).exactly(2).times
12
+ # expect(foo).to receive(:bar).at_least(1).times
13
+ # expect(foo).to receive(:bar).at_least(2).times
14
+ # expect(foo).to receive(:bar).at_most(1).times
15
+ # expect(foo).to receive(:bar).at_most(2).times
9
16
  #
10
- # # bad
11
- # expect(foo).to receive(:bar).exactly(1).times
12
- # expect(foo).to receive(:bar).exactly(2).times
13
- # expect(foo).to receive(:bar).at_least(1).times
14
- # expect(foo).to receive(:bar).at_least(2).times
15
- # expect(foo).to receive(:bar).at_most(1).times
16
- # expect(foo).to receive(:bar).at_most(2).times
17
- #
18
- # # good
19
- # expect(foo).to receive(:bar).once
20
- # expect(foo).to receive(:bar).twice
21
- # expect(foo).to receive(:bar).at_least(:once)
22
- # expect(foo).to receive(:bar).at_least(:twice)
23
- # expect(foo).to receive(:bar).at_most(:once)
24
- # expect(foo).to receive(:bar).at_most(:twice).times
17
+ # # good
18
+ # expect(foo).to receive(:bar).once
19
+ # expect(foo).to receive(:bar).twice
20
+ # expect(foo).to receive(:bar).at_least(:once)
21
+ # expect(foo).to receive(:bar).at_least(:twice)
22
+ # expect(foo).to receive(:bar).at_most(:once)
23
+ # expect(foo).to receive(:bar).at_most(:twice).times
25
24
  #
26
25
  class ReceiveCounts < Base
27
26
  extend AutoCorrector
@@ -6,12 +6,11 @@ module RuboCop
6
6
  # Prefer `not_to receive(...)` over `receive(...).never`.
7
7
  #
8
8
  # @example
9
+ # # bad
10
+ # expect(foo).to receive(:bar).never
9
11
  #
10
- # # bad
11
- # expect(foo).to receive(:bar).never
12
- #
13
- # # good
14
- # expect(foo).not_to receive(:bar)
12
+ # # good
13
+ # expect(foo).not_to receive(:bar)
15
14
  #
16
15
  class ReceiveNever < Base
17
16
  extend AutoCorrector
@@ -6,44 +6,43 @@ module RuboCop
6
6
  # Check for repeated description strings in example groups.
7
7
  #
8
8
  # @example
9
+ # # bad
10
+ # RSpec.describe User do
11
+ # it 'is valid' do
12
+ # # ...
13
+ # end
9
14
  #
10
- # # bad
11
- # RSpec.describe User do
12
- # it 'is valid' do
13
- # # ...
14
- # end
15
- #
16
- # it 'is valid' do
17
- # # ...
18
- # end
15
+ # it 'is valid' do
16
+ # # ...
19
17
  # end
18
+ # end
20
19
  #
21
- # # good
22
- # RSpec.describe User do
23
- # it 'is valid when first and last name are present' do
24
- # # ...
25
- # end
20
+ # # good
21
+ # RSpec.describe User do
22
+ # it 'is valid when first and last name are present' do
23
+ # # ...
24
+ # end
26
25
  #
27
- # it 'is valid when last name only is present' do
28
- # # ...
29
- # end
26
+ # it 'is valid when last name only is present' do
27
+ # # ...
30
28
  # end
29
+ # end
31
30
  #
32
- # # good
33
- # RSpec.describe User do
34
- # it 'is valid' do
35
- # # ...
36
- # end
31
+ # # good
32
+ # RSpec.describe User do
33
+ # it 'is valid' do
34
+ # # ...
35
+ # end
37
36
  #
38
- # it 'is valid', :flag do
39
- # # ...
40
- # end
37
+ # it 'is valid', :flag do
38
+ # # ...
41
39
  # end
40
+ # end
42
41
  #
43
42
  class RepeatedDescription < Base
44
43
  MSG = "Don't repeat descriptions within an example group."
45
44
 
46
- def on_block(node)
45
+ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
47
46
  return unless example_group?(node)
48
47
 
49
48
  repeated_descriptions(node).each do |repeated_description|
@@ -18,7 +18,7 @@ module RuboCop
18
18
  class RepeatedExample < Base
19
19
  MSG = "Don't repeat examples within an example group."
20
20
 
21
- def on_block(node)
21
+ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
22
22
  return unless example_group?(node)
23
23
 
24
24
  repeated_examples(node).each do |repeated_example|
@@ -6,42 +6,41 @@ module RuboCop
6
6
  # Check for repeated describe and context block body.
7
7
  #
8
8
  # @example
9
+ # # bad
10
+ # describe 'cool feature x' do
11
+ # it { cool_predicate }
12
+ # end
9
13
  #
10
- # # bad
11
- # describe 'cool feature x' do
12
- # it { cool_predicate }
13
- # end
14
+ # describe 'cool feature y' do
15
+ # it { cool_predicate }
16
+ # end
14
17
  #
15
- # describe 'cool feature y' do
16
- # it { cool_predicate }
17
- # end
18
+ # # good
19
+ # describe 'cool feature' do
20
+ # it { cool_predicate }
21
+ # end
18
22
  #
19
- # # good
20
- # describe 'cool feature' do
21
- # it { cool_predicate }
22
- # end
23
+ # describe 'another cool feature' do
24
+ # it { another_predicate }
25
+ # end
23
26
  #
24
- # describe 'another cool feature' do
25
- # it { another_predicate }
26
- # end
27
+ # # good
28
+ # context 'when case x', :tag do
29
+ # it { cool_predicate }
30
+ # end
27
31
  #
28
- # # good
29
- # context 'when case x', :tag do
30
- # it { cool_predicate }
31
- # end
32
+ # context 'when case y' do
33
+ # it { cool_predicate }
34
+ # end
32
35
  #
33
- # context 'when case y' do
34
- # it { cool_predicate }
35
- # end
36
+ # # good
37
+ # context Array do
38
+ # it { is_expected.to respond_to :each }
39
+ # end
36
40
  #
37
- # # good
38
- # context Array do
39
- # it { is_expected.to respond_to :each }
40
- # end
41
- #
42
- # context Hash do
43
- # it { is_expected.to respond_to :each }
44
- # end
41
+ # context Hash do
42
+ # it { is_expected.to respond_to :each }
43
+ # end
45
44
  #
46
45
  class RepeatedExampleGroupBody < Base
47
46
  MSG = 'Repeated %<group>s block body on line(s) %<loc>s'
@@ -6,42 +6,41 @@ module RuboCop
6
6
  # Check for repeated example group descriptions.
7
7
  #
8
8
  # @example
9
+ # # bad
10
+ # describe 'cool feature' do
11
+ # # example group
12
+ # end
9
13
  #
10
- # # bad
11
- # describe 'cool feature' do
12
- # # example group
13
- # end
14
+ # describe 'cool feature' do
15
+ # # example group
16
+ # end
14
17
  #
15
- # describe 'cool feature' do
16
- # # example group
17
- # end
18
+ # # bad
19
+ # context 'when case x' do
20
+ # # example group
21
+ # end
18
22
  #
19
- # # bad
20
- # context 'when case x' do
21
- # # example group
22
- # end
23
+ # describe 'when case x' do
24
+ # # example group
25
+ # end
23
26
  #
24
- # describe 'when case x' do
25
- # # example group
26
- # end
27
+ # # good
28
+ # describe 'cool feature' do
29
+ # # example group
30
+ # end
27
31
  #
28
- # # good
29
- # describe 'cool feature' do
30
- # # example group
31
- # end
32
+ # describe 'another cool feature' do
33
+ # # example group
34
+ # end
32
35
  #
33
- # describe 'another cool feature' do
34
- # # example group
35
- # end
36
+ # # good
37
+ # context 'when case x' do
38
+ # # example group
39
+ # end
36
40
  #
37
- # # good
38
- # context 'when case x' do
39
- # # example group
40
- # end
41
- #
42
- # context 'when another case' do
43
- # # example group
44
- # end
41
+ # context 'when another case' do
42
+ # # example group
43
+ # end
45
44
  #
46
45
  class RepeatedExampleGroupDescription < Base
47
46
  MSG = 'Repeated %<group>s block description on line(s) %<loc>s'
@@ -6,45 +6,44 @@ module RuboCop
6
6
  # Check for repeated include of shared examples.
7
7
  #
8
8
  # @example
9
+ # # bad
10
+ # describe 'foo' do
11
+ # include_examples 'cool stuff'
12
+ # include_examples 'cool stuff'
13
+ # end
9
14
  #
10
- # # bad
11
- # describe 'foo' do
12
- # include_examples 'cool stuff'
13
- # include_examples 'cool stuff'
14
- # end
15
+ # # bad
16
+ # describe 'foo' do
17
+ # it_behaves_like 'a cool', 'thing'
18
+ # it_behaves_like 'a cool', 'thing'
19
+ # end
15
20
  #
16
- # # bad
17
- # describe 'foo' do
18
- # it_behaves_like 'a cool', 'thing'
19
- # it_behaves_like 'a cool', 'thing'
20
- # end
21
+ # # bad
22
+ # context 'foo' do
23
+ # it_should_behave_like 'a duck'
24
+ # it_should_behave_like 'a duck'
25
+ # end
21
26
  #
22
- # # bad
23
- # context 'foo' do
24
- # it_should_behave_like 'a duck'
25
- # it_should_behave_like 'a duck'
26
- # end
27
+ # # good
28
+ # describe 'foo' do
29
+ # include_examples 'cool stuff'
30
+ # end
27
31
  #
28
- # # good
29
- # describe 'foo' do
30
- # include_examples 'cool stuff'
31
- # end
32
+ # describe 'bar' do
33
+ # include_examples 'cool stuff'
34
+ # end
32
35
  #
33
- # describe 'bar' do
34
- # include_examples 'cool stuff'
35
- # end
36
+ # # good
37
+ # describe 'foo' do
38
+ # it_behaves_like 'a cool', 'thing'
39
+ # it_behaves_like 'a cool', 'person'
40
+ # end
36
41
  #
37
- # # good
38
- # describe 'foo' do
39
- # it_behaves_like 'a cool', 'thing'
40
- # it_behaves_like 'a cool', 'person'
41
- # end
42
- #
43
- # # good
44
- # context 'foo' do
45
- # it_should_behave_like 'a duck'
46
- # it_should_behave_like 'a goose'
47
- # end
42
+ # # good
43
+ # context 'foo' do
44
+ # it_should_behave_like 'a duck'
45
+ # it_should_behave_like 'a goose'
46
+ # end
48
47
  #
49
48
  class RepeatedIncludeExample < Base
50
49
  MSG = 'Repeated include of shared_examples %<name>s ' \
@@ -59,7 +59,7 @@ module RuboCop
59
59
  check_and_return_call(node)
60
60
  end
61
61
 
62
- def on_block(node)
62
+ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
63
63
  return unless style == :and_return
64
64
  return unless stub_with_block?(node)
65
65
 
@@ -31,7 +31,7 @@ module RuboCop
31
31
 
32
32
  MSG = 'Group all let/let! blocks in the example group together.'
33
33
 
34
- def on_block(node)
34
+ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
35
35
  return unless example_group_with_body?(node)
36
36
 
37
37
  check_let_declarations(node.body)
@@ -53,10 +53,6 @@ module RuboCop
53
53
  end
54
54
  end
55
55
  end
56
-
57
- def find_first_let(node)
58
- node.children.find { |child| let?(child) }
59
- end
60
56
  end
61
57
  end
62
58
  end
@@ -26,7 +26,7 @@ module RuboCop
26
26
  MSG = 'Do not define multiple `%<hook_name>s` hooks in the same ' \
27
27
  'example group (also defined on %<lines>s).'
28
28
 
29
- def on_block(node)
29
+ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
30
30
  return unless example_group?(node)
31
31
 
32
32
  repeated_hooks(node).each do |occurrences|
@@ -79,7 +79,7 @@ module RuboCop
79
79
  def_node_matcher :shared_example,
80
80
  block_pattern('#SharedGroups.examples')
81
81
 
82
- def on_block(node)
82
+ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
83
83
  context_with_only_examples(node) do
84
84
  add_offense(node.send_node, message: MSG_EXAMPLES) do |corrector|
85
85
  corrector.replace(node.send_node.loc.selector, 'shared_examples')
@@ -6,7 +6,6 @@ module RuboCop
6
6
  # Checks that message expectations do not have a configured response.
7
7
  #
8
8
  # @example
9
- #
10
9
  # # bad
11
10
  # expect(foo).to receive(:bar).with(42).and_return("hello world")
12
11
  #
@@ -6,7 +6,6 @@ module RuboCop
6
6
  # Ensure that subject is defined using subject helper.
7
7
  #
8
8
  # @example
9
- #
10
9
  # # bad
11
10
  # let(:subject) { foo }
12
11
  # let!(:subject) { foo }
@@ -11,7 +11,7 @@ module RuboCop
11
11
  # when subject is also defined in parent example groups.
12
12
  #
13
13
  # @see https://robots.thoughtbot.com/don-t-stub-the-system-under-test
14
- # @see https://samphippen.com/introducing-rspec-smells-and-where-to-find-them#smell-1-stubject
14
+ # @see https://penelope.zone/2015/12/27/introducing-rspec-smells-and-where-to-find-them.html#smell-1-stubjec
15
15
  # @see https://github.com/rubocop-hq/rspec-style-guide#dont-stub-subject
16
16
  #
17
17
  # @example
@@ -72,7 +72,7 @@ module RuboCop
72
72
  def_node_matcher :subject?, <<-PATTERN
73
73
  (block
74
74
  (send nil?
75
- {:subject (sym $_) | $:subject}
75
+ { #Subjects.all (sym $_) | $#Subjects.all }
76
76
  ) args ...)
77
77
  PATTERN
78
78
 
@@ -10,26 +10,26 @@ module RuboCop
10
10
  # to `raise_error`
11
11
  #
12
12
  # @example
13
+ # # bad
14
+ # expect {
15
+ # raise StandardError.new('error')
16
+ # }.to raise_error
13
17
  #
14
- # # bad
15
- # expect {
16
- # raise StandardError.new('error')
17
- # }.to raise_error
18
+ # # good
19
+ # expect {
20
+ # raise StandardError.new('error')
21
+ # }.to raise_error(StandardError)
18
22
  #
19
- # # good
20
- # expect {
21
- # raise StandardError.new('error')
22
- # }.to raise_error(StandardError)
23
+ # expect {
24
+ # raise StandardError.new('error')
25
+ # }.to raise_error('error')
23
26
  #
24
- # expect {
25
- # raise StandardError.new('error')
26
- # }.to raise_error('error')
27
+ # expect {
28
+ # raise StandardError.new('error')
29
+ # }.to raise_error(/err/)
27
30
  #
28
- # expect {
29
- # raise StandardError.new('error')
30
- # }.to raise_error(/err/)
31
+ # expect { do_something }.not_to raise_error
31
32
  #
32
- # expect { do_something }.not_to raise_error
33
33
  class UnspecifiedException < Base
34
34
  MSG = 'Specify the exception being captured'
35
35
  RESTRICT_ON_SEND = %i[to].freeze
@@ -22,6 +22,7 @@ module RuboCop
22
22
  # # good
23
23
  # subject('user') { create_user }
24
24
  # let('user_name') { 'Adam' }
25
+ #
25
26
  class VariableDefinition < Base
26
27
  extend AutoCorrector
27
28
  include ConfigurableEnforcedStyle
@@ -5,7 +5,7 @@ module RuboCop
5
5
  module RSpec
6
6
  # Checks that memoized helper names use the configured style.
7
7
  #
8
- # Variables can be excluded from checking using the `IgnoredPatterns`
8
+ # Variables can be excluded from checking using the `AllowedPatterns`
9
9
  # option.
10
10
  #
11
11
  # @example EnforcedStyle: snake_case (default)
@@ -26,22 +26,21 @@ module RuboCop
26
26
  # subject(:userName1) { 'Adam' }
27
27
  # let(:userName2) { 'Adam' }
28
28
  #
29
- # @example IgnoredPatterns configuration
30
- #
29
+ # @example AllowedPatterns configuration
31
30
  # # rubocop.yml
32
31
  # # RSpec/VariableName:
33
32
  # # EnforcedStyle: snake_case
34
- # # IgnoredPatterns:
33
+ # # AllowedPatterns:
35
34
  # # - ^userFood
36
35
  #
37
36
  # @example
38
- # # okay because it matches the `^userFood` regex in `IgnoredPatterns`
37
+ # # okay because it matches the `^userFood` regex in `AllowedPatterns`
39
38
  # subject(:userFood_1) { 'spaghetti' }
40
39
  # let(:userFood_2) { 'fettuccine' }
41
40
  #
42
41
  class VariableName < Base
43
42
  include ConfigurableNaming
44
- include IgnoredPattern
43
+ include AllowedPattern
45
44
  include Variable
46
45
 
47
46
  MSG = 'Use %<style>s for variable names.'
@@ -49,7 +48,7 @@ module RuboCop
49
48
  def on_send(node)
50
49
  variable_definition?(node) do |variable|
51
50
  return if variable.dstr_type? || variable.dsym_type?
52
- return if matches_ignored_pattern?(variable.value)
51
+ return if matches_allowed_pattern?(variable.value)
53
52
 
54
53
  check_name(node, variable.value, variable.loc.expression)
55
54
  end
@@ -22,6 +22,7 @@ module RuboCop
22
22
  # let(:foo) do
23
23
  # instance_double("ClassName", method_name: 'returned value')
24
24
  # end
25
+ #
25
26
  class VerifiedDoubles < Base
26
27
  MSG = 'Prefer using verifying doubles over normal doubles.'
27
28
  RESTRICT_ON_SEND = %i[double spy].freeze
@@ -11,6 +11,7 @@ module RuboCop
11
11
  #
12
12
  # # good
13
13
  # expect(something).to be(1)
14
+ #
14
15
  class VoidExpect < Base
15
16
  MSG = 'Do not use `expect()` without `.to` or `.not_to`. ' \
16
17
  'Chain the methods or remove it.'
@@ -32,7 +33,7 @@ module RuboCop
32
33
  check_expect(node)
33
34
  end
34
35
 
35
- def on_block(node)
36
+ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
36
37
  return unless expect_block?(node)
37
38
 
38
39
  check_expect(node)
@@ -11,6 +11,7 @@ module RuboCop
11
11
  #
12
12
  # # good
13
13
  # expect(foo).to receive(:bar).and_yield(1)
14
+ #
14
15
  class Yield < Base
15
16
  extend AutoCorrector
16
17
  include RangeHelp
@@ -26,7 +27,7 @@ module RuboCop
26
27
  # @!method block_call?(node)
27
28
  def_node_matcher :block_call?, '(send (lvar %) :call ...)'
28
29
 
29
- def on_block(node)
30
+ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
30
31
  return unless method_on_stub?(node.send_node)
31
32
 
32
33
  block_arg(node.arguments) do |block|
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative 'rspec/capybara/current_path_expectation'
4
4
  require_relative 'rspec/capybara/feature_methods'
5
+ require_relative 'rspec/capybara/specific_finders'
5
6
  require_relative 'rspec/capybara/specific_matcher'
6
7
  require_relative 'rspec/capybara/visibility_matcher'
7
8
 
@@ -28,6 +29,7 @@ require_relative 'rspec/be_eql'
28
29
  require_relative 'rspec/be_nil'
29
30
  require_relative 'rspec/before_after_all'
30
31
  require_relative 'rspec/change_by_zero'
32
+ require_relative 'rspec/class_check'
31
33
  require_relative 'rspec/context_method'
32
34
  require_relative 'rspec/context_wording'
33
35
  require_relative 'rspec/describe_class'
@@ -77,6 +79,7 @@ require_relative 'rspec/multiple_memoized_helpers'
77
79
  require_relative 'rspec/multiple_subjects'
78
80
  require_relative 'rspec/named_subject'
79
81
  require_relative 'rspec/nested_groups'
82
+ require_relative 'rspec/no_expectation_example'
80
83
  require_relative 'rspec/not_to_not'
81
84
  require_relative 'rspec/overwriting_setup'
82
85
  require_relative 'rspec/pending'