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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06d6fd83af093abc4da74f5791334c364b86c8238610e53890f4b197f97ce1b6
4
- data.tar.gz: 3e40ac4c4e15bee0892061da115755ad8a9cc872218b8cf2d8fe166ea40c6f83
3
+ metadata.gz: beb4503a6d6d420e50748e9fd6c679a2968888d783293c33da2dbaf6d7a9fc3f
4
+ data.tar.gz: 4dff5e6a61c80d1acc943169efdb65a24fa5dd05654bf758c4f6b291aedad63c
5
5
  SHA512:
6
- metadata.gz: d84bfa56ac9503ad57e0dea9e5207469a3acf8d086e1ef0bf3f8239a9a704f4ce40e7ce82e10596699d948217ff55347098e0421af042e3653e6e3ea0b7e3593
7
- data.tar.gz: c643ac0b7e06972fb90347dff8684b4c94e08ca3e9a85a5406bf87c3ce6f88f4395e878dce7fae224049127cc53dcb4639e6fb5d5d6134da9fd4dff6013480ca
6
+ metadata.gz: 7937a46e61db588b4b9354ec362af79585526e7d95a7bc735435ace552b44e354f32e8f10310460059b71870a1caf8617414edd663cf8b50e9f13405977123a4
7
+ data.tar.gz: 7c4a57c7635e827717d10f253233837e7b9c11c5769fd4d9aab7c7c110d808f83c6099663684237c499432f606891b7a8aa9142c302e09ad5e73391b70f29a8e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,37 @@
2
2
 
3
3
  ## Master (Unreleased)
4
4
 
5
+ ## 2.13.1 (2022-09-12)
6
+
7
+ * Include config/obsoletion.yml in the gemspec. ([@hosamaly][])
8
+
9
+ ## 2.13.0 (2022-09-12)
10
+
11
+ * Fix `RSpec/FilePath` cop missing mismatched expanded namespace. ([@sl4vr][])
12
+ * Add new `AllowConsecutiveOneLiners` (default true) option for `Rspec/EmptyLineAfterHook` cop. ([@ngouy][])
13
+ * Add autocorrect support for `RSpec/EmptyExampleGroup`. ([@r7kamura][])
14
+ * Fix `RSpec/ChangeByZero` with compound expressions using `&` or `|` operators. ([@BrianHawley][])
15
+ * Add `RSpec/NoExpectationExample`. ([@r7kamura][])
16
+ * Add some expectation methods to default configuration. ([@r7kamura][])
17
+ * Fix a false positive for `RSpec/Capybara/SpecificMatcher`. ([@ydah][])
18
+ * Fix a false negative for `RSpec/Capybara/SpecificMatcher` for `have_field`. ([@ydah][])
19
+ * Fix a false positive for `RSpec/Capybara/SpecificMatcher` when may not have a `href` by `have_link`. ([@ydah][])
20
+ * Add `NegatedMatcher` configuration option to `RSpec/ChangeByZero`. ([@ydah][])
21
+ * Add new `RSpec/Capybara/SpecificFinders` cop. ([@ydah][])
22
+ * Add support for numblocks to `RSpec/AroundBlock`, `RSpec/EmptyLineAfterHook`, `RSpec/ExpectInHook`, `RSpec/HookArgument`, `RSpec/HooksBeforeExamples`, `RSpec/IteratedExpectation`, and `RSpec/NoExpectationExample`. ([@ydah][])
23
+ * Fix incorrect documentation URLs when using `rubocop --show-docs-url`. ([@r7kamura][])
24
+ * Add `AllowedGroups` configuration option to `RSpec/NestedGroups`. ([@ydah][])
25
+ * Deprecate `IgnoredPatterns` option in favor of the `AllowedPatterns` options. ([@ydah][])
26
+ * Add `AllowedPatterns` configuration option to `RSpec/ContextWording`. ([@ydah][])
27
+ * Add `RSpec/ClassCheck` cop. ([@r7kamura][])
28
+ * Fix a false positive for `RSpec/Capybara/SpecificMatcher` when pseudo-classes. ([@ydah][])
29
+ * Fix a false negative for `RSpec/SubjectStub` when the subject is declared with the `subject!` method and called by name. ([@eikes][])
30
+ * Support `Array.new(n)` on `RSpec/FactoryBot/CreateList` cop. ([@r7kamura][])
31
+
32
+ ## 2.12.1 (2022-07-03)
33
+
34
+ * Fix a false positive for `RSpec/Capybara/SpecificMatcher`. ([@ydah][])
35
+
5
36
  ## 2.12.0 (2022-07-02)
6
37
 
7
38
  * Fix incorrect path suggested by `RSpec/FilePath` cop when second argument contains spaces. ([@tejasbubane][])
@@ -599,114 +630,115 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
599
630
  * Split `UnitSpecNaming` cop into `RSpecDescribeClass`, `RSpecDescribeMethod` and `RSpecFileName` and enabled them all by default. ([@geniou][])
600
631
  * Add `RSpecExampleWording` cop to prevent to use of should at the beginning of the spec description. ([@geniou][])
601
632
  * Fix `RSpecFileName` cop for non-class specs. ([@geniou][])
602
- * Adapt `RSpecFileName` cop to commen naming convention and skip spec with multiple top level describes. ([@geniou][])
633
+ * Adapt `RSpecFileName` cop to common naming convention and skip spec with multiple top level describes. ([@geniou][])
603
634
  * Add `RSpecMultipleDescribes` cop to check for multiple top level describes. ([@geniou][])
604
635
  * Add `RSpecDescribedClass` to promote the use of `described_class`. ([@geniou][])
605
636
  * Add `RSpecInstanceVariable` cop to check for the usage of instance variables. ([@geniou][])
606
637
 
607
- <!-- Contributors -->
638
+ <!-- Contributors (alphabetically) -->
608
639
 
640
+ [@abrom]: https://github.com/abrom
641
+ [@ahukkanen]: https://github.com/ahukkanen
642
+ [@akiomik]: https://github.com/akiomik
643
+ [@AlexWayfer]: https://github.com/AlexWayfer
644
+ [@andrykonchin]: https://github.com/andrykonchin
609
645
  [@andyw8]: https://github.com/andyw8
646
+ [@anthony-robin]: https://github.com/anthony-robin
647
+ [@aried3r]: https://github.com/aried3r
648
+ [@baberthal]: https://github.com/baberthal
610
649
  [@backus]: https://github.com/backus
650
+ [@biinari]: https://github.com/biinari
651
+ [@bmorrall]: https://github.com/bmorrall
611
652
  [@bquorning]: https://github.com/bquorning
653
+ [@BrentWheeldon]: https://github.com/BrentWheeldon
654
+ [@BrianHawley]: https://github.com/BrianHawley
655
+ [@cfabianski]: https://github.com/cfabianski
656
+ [@clupprich]: https://github.com/clupprich
657
+ [@composerinteralia]: https://github.com/composerinteralia
658
+ [@Darhazer]: https://github.com/Darhazer
659
+ [@daveworth]: https://github.com/daveworth
660
+ [@dduugg]: https://github.com/dduugg
612
661
  [@deivid-rodriguez]: https://github.com/deivid-rodriguez
662
+ [@dgollahon]: https://github.com/dgollahon
663
+ [@Drowze]: https://github.com/Drowze
664
+ [@dswij]: https://github.com/dswij
665
+ [@dvandersluis]: https://github.com/dvandersluis
666
+ [@edgibbs]: https://github.com/edgibbs
667
+ [@eikes]: https://github.com/eikes
668
+ [@eitoball]: https://github.com/eitoball
669
+ [@elebow]: https://github.com/elebow
670
+ [@EliseFitz15]: https://github.com/EliseFitz15
671
+ [@elliterate]: https://github.com/elliterate
672
+ [@foton]: https://github.com/foton
673
+ [@francois-ferrandis]: https://github.com/francois-ferrandis
674
+ [@G-Rath]: https://github.com/G-Rath
613
675
  [@geniou]: https://github.com/geniou
676
+ [@gsamokovarov]: https://github.com/gsamokovarov
677
+ [@harry-graham]: https://github.com/harry-graham
678
+ [@harrylewis]: https://github.com/harrylewis
679
+ [@hosamaly]: https://github.com/hosamaly
614
680
  [@jaredbeck]: https://github.com/jaredbeck
615
- [@jawshooah]: https://github.com/jawshooah
616
- [@nevir]: https://github.com/nevir
617
- [@nijikon]: https://github.com/nijikon
618
- [@pstengel]: https://github.com/pstengel
619
- [@miguelfteixeira]: https://github.com/miguelfteixeira
620
- [@mlarraz]: https://github.com/mlarraz
621
- [@renanborgescampos]: https://github.com/renanborgescampos
622
681
  [@jaredmoody]: https://github.com/jaredmoody
623
- [@baberthal]: https://github.com/baberthal
624
682
  [@jeffreyc]: https://github.com/jeffreyc
625
- [@clupprich]: https://github.com/clupprich
626
- [@onk]: https://github.com/onk
627
- [@Darhazer]: https://github.com/Darhazer
628
- [@redross]: https://github.com/redross
629
- [@cfabianski]: https://github.com/cfabianski
630
- [@dgollahon]: https://github.com/dgollahon
631
- [@rspeicher]: https://github.com/rspeicher
632
- [@jonatas]: https://github.com/jonatas
633
- [@pocke]: https://github.com/pocke
634
- [@bmorrall]: https://github.com/bmorrall
635
- [@zverok]: https://github.com/zverok
636
- [@timrogers]: https://github.com/timrogers
637
- [@yevhene]: https://github.com/yevhene
638
- [@walf443]: https://github.com/walf443
639
- [@pirj]: https://github.com/pirj
640
- [@telmofcosta]: https://github.com/telmofcosta
641
- [@EliseFitz15]: https://github.com/EliseFitz15
642
- [@anthony-robin]: https://github.com/anthony-robin
683
+ [@jfragoulis]: https://github.com/jfragoulis
684
+ [@johnny-miyake]: https://github.com/johnny-miyake
643
685
  [@jojos003]: https://github.com/jojos003
644
- [@abrom]: https://github.com/abrom
645
- [@patrickomatic]: https://github.com/patrickomatic
646
- [@tdeo]: https://github.com/tdeo
647
- [@composerinteralia]: https://github.com/composerinteralia
648
- [@seanpdoyle]: https://github.com/seanpdoyle
649
- [@vzvu3k6k]: https://github.com/vzvu3k6k
650
- [@BrentWheeldon]: https://github.com/BrentWheeldon
651
- [@daveworth]: https://github.com/daveworth
652
- [@RST-J]: https://github.com/RST-J
653
- [@ypresto]: https://github.com/ypresto
686
+ [@jonatas]: https://github.com/jonatas
687
+ [@jtannas]: https://github.com/jtannas
688
+ [@kellysutton]: https://github.com/kellysutton
689
+ [@koic]: https://github.com/koic
690
+ [@lazycoder9]: https://github.com/lazycoder9
691
+ [@leoarnold]: https://github.com/leoarnold
692
+ [@lokhi]: https://github.com/lokhi
693
+ [@luke-hill]: https://github.com/luke-hill
694
+ [@M-Yamashita01]: https://github.com/M-Yamashita01
695
+ [@miguelfteixeira]: https://github.com/miguelfteixeira
654
696
  [@mkenyon]: https://github.com/mkenyon
655
- [@gsamokovarov]: https://github.com/gsamokovarov
656
- [@schmijos]: https://github.com/schmijos
657
- [@foton]: https://github.com/foton
697
+ [@mkrawc]: https://github.com/mkrawc
698
+ [@mlarraz]: https://github.com/mlarraz
699
+ [@mockdeep]: https://github.com/mockdeep
700
+ [@MothOnMars]: https://github.com/MothOnMars
658
701
  [@nc-holodakg]: https://github.com/nc-holodakg
659
- [@onumis]: https://github.com/onumis
702
+ [@nevir]: https://github.com/nevir
703
+ [@ngouy]: https://github.com/ngouy
660
704
  [@nickcampbell18]: https://github.com/nickcampbell18
705
+ [@nijikon]: https://github.com/nijikon
706
+ [@onk]: https://github.com/onk
707
+ [@onumis]: https://github.com/onumis
708
+ [@oshiro3]: https://github.com/oshiro3
709
+ [@patrickomatic]: https://github.com/patrickomatic
710
+ [@paydaylight]: https://github.com/paydaylight
711
+ [@PhilCoggins]: https://github.com/PhilCoggins
712
+ [@pirj]: https://github.com/pirj
713
+ [@pocke]: https://github.com/pocke
714
+ [@pstengel]: https://github.com/pstengel
661
715
  [@QQism]: https://github.com/QQism
662
- [@kellysutton]: https://github.com/kellysutton
663
- [@mkrawc]: https://github.com/mkrawc
664
- [@jfragoulis]: https://github.com/jfragoulis
665
- [@ybiquitous]: https://github.com/ybiquitous
666
- [@dduugg]: https://github.com/dduugg
667
- [@lazycoder9]: https://github.com/lazycoder9
668
- [@elebow]: https://github.com/elebow
669
- [@eitoball]: https://github.com/eitoball
670
- [@aried3r]: https://github.com/aried3r
671
- [@AlexWayfer]: https://github.com/AlexWayfer
672
- [@tejasbubane]: https://github.com/tejasbubane
673
- [@twalpole]: https://github.com/twalpole
674
- [@zdennis]: https://github.com/zdennis
716
+ [@r7kamura]: https://github.com/r7kamura
717
+ [@Rafix02]: https://github.com/Rafix02
718
+ [@redross]: https://github.com/redross
719
+ [@renanborgescampos]: https://github.com/renanborgescampos
675
720
  [@robotdana]: https://github.com/robotdana
676
721
  [@rolfschmidt]: https://github.com/rolfschmidt
677
- [@andrykonchin]: https://github.com/andrykonchin
678
- [@harrylewis]: https://github.com/harrylewis
679
- [@elliterate]: https://github.com/elliterate
680
- [@jtannas]: https://github.com/jtannas
681
- [@mockdeep]: https://github.com/mockdeep
682
- [@biinari]: https://github.com/biinari
683
- [@koic]: https://github.com/koic
684
- [@Rafix02]: https://github.com/Rafix02
685
- [@PhilCoggins]: https://github.com/PhilCoggins
722
+ [@rrosenblum]: https://github.com/rrosenblum
723
+ [@rspeicher]: https://github.com/rspeicher
724
+ [@RST-J]: https://github.com/RST-J
725
+ [@schmijos]: https://github.com/schmijos
726
+ [@seanpdoyle]: https://github.com/seanpdoyle
686
727
  [@sl4vr]: https://github.com/sl4vr
687
- [@ahukkanen]: https://github.com/ahukkanen
688
- [@dvandersluis]: https://github.com/dvandersluis
689
- [@hosamaly]: https://github.com/hosamaly
690
728
  [@stephannv]: https://github.com/stephannv
729
+ [@t3h2mas]: https://github.com/t3h2mas
730
+ [@tdeo]: https://github.com/tdeo
731
+ [@tejasbubane]: https://github.com/tejasbubane
732
+ [@telmofcosta]: https://github.com/telmofcosta
691
733
  [@Tietew]: https://github.com/Tietew
692
- [@rrosenblum]: https://github.com/rrosenblum
693
- [@paydaylight]: https://github.com/paydaylight
734
+ [@timrogers]: https://github.com/timrogers
694
735
  [@topalovic]: https://github.com/topalovic
695
- [@lokhi]: https://github.com/lokhi
696
- [@MothOnMars]: https://github.com/MothOnMars
697
- [@G-Rath]: https://github.com/G-Rath
698
- [@dswij]: https://github.com/dswij
699
- [@francois-ferrandis]: https://github.com/francois-ferrandis
700
- [@r7kamura]: https://github.com/r7kamura
701
- [@leoarnold]: https://github.com/leoarnold
702
- [@harry-graham]: https://github.com/harry-graham
703
- [@oshiro3]: https://github.com/oshiro3
736
+ [@twalpole]: https://github.com/twalpole
737
+ [@vzvu3k6k]: https://github.com/vzvu3k6k
738
+ [@walf443]: https://github.com/walf443
739
+ [@ybiquitous]: https://github.com/ybiquitous
704
740
  [@ydah]: https://github.com/ydah
705
- [@t3h2mas]: https://github.com/t3h2mas
706
- [@M-Yamashita01]: https://github.com/M-Yamashita01
707
- [@luke-hill]: https://github.com/luke-hill
708
- [@johnny-miyake]: https://github.com/johnny-miyake
709
- [@ngouy]: https://github.com/ngouy
710
- [@edgibbs]: https://github.com/edgibbs
711
- [@Drowze]: https://github.com/Drowze
712
- [@akiomik]: https://github.com/akiomik
741
+ [@yevhene]: https://github.com/yevhene
742
+ [@ypresto]: https://github.com/ypresto
743
+ [@zdennis]: https://github.com/zdennis
744
+ [@zverok]: https://github.com/zverok
data/config/default.yml CHANGED
@@ -2,6 +2,7 @@
2
2
  RSpec:
3
3
  Enabled: true
4
4
  StyleGuideBaseURL: https://rspec.rubystyle.guide
5
+ DocumentationBaseURL: https://docs.rubocop.org/rubocop-rspec
5
6
  Include: &1
6
7
  - "**/*_spec.rb"
7
8
  - "**/spec/**/*"
@@ -61,9 +62,14 @@ RSpec:
61
62
  Pending:
62
63
  - pending
63
64
  Expectations:
65
+ - are_expected
64
66
  - expect
65
- - is_expected
66
67
  - expect_any_instance_of
68
+ - is_expected
69
+ - should
70
+ - should_not
71
+ - should_not_receive
72
+ - should_receive
67
73
  Helpers:
68
74
  - let
69
75
  - let!
@@ -187,8 +193,21 @@ RSpec/BeforeAfterAll:
187
193
  RSpec/ChangeByZero:
188
194
  Description: Prefer negated matchers over `to change.by(0)`.
189
195
  Enabled: pending
190
- VersionAdded: 2.11.0
196
+ VersionAdded: '2.11'
197
+ VersionChanged: '2.13'
191
198
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ChangeByZero
199
+ NegatedMatcher: ~
200
+
201
+ RSpec/ClassCheck:
202
+ Description: Enforces consistent use of `be_a` or `be_kind_of`.
203
+ StyleGuide: "#is-a-vs-kind-of"
204
+ Enabled: pending
205
+ VersionAdded: '2.13'
206
+ EnforcedStyle: be_a
207
+ SupportedStyles:
208
+ - be_a
209
+ - be_kind_of
210
+ Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ClassCheck
192
211
 
193
212
  RSpec/ContextMethod:
194
213
  Description: "`context` should not be used for specifying methods."
@@ -204,8 +223,9 @@ RSpec/ContextWording:
204
223
  - when
205
224
  - with
206
225
  - without
226
+ AllowedPatterns: []
207
227
  VersionAdded: '1.20'
208
- VersionChanged: 1.20.1
228
+ VersionChanged: '2.13'
209
229
  StyleGuide: https://rspec.rubystyle.guide/#context-descriptions
210
230
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ContextWording
211
231
 
@@ -279,8 +299,9 @@ RSpec/Dialect:
279
299
  RSpec/EmptyExampleGroup:
280
300
  Description: Checks if an example group does not include any tests.
281
301
  Enabled: true
302
+ SafeAutoCorrect: false
282
303
  VersionAdded: '1.7'
283
- VersionChanged: '2.0'
304
+ VersionChanged: '2.13'
284
305
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyExampleGroup
285
306
 
286
307
  RSpec/EmptyHook:
@@ -315,8 +336,10 @@ RSpec/EmptyLineAfterHook:
315
336
  Description: Checks if there is an empty line after hook blocks.
316
337
  Enabled: true
317
338
  VersionAdded: '1.27'
339
+ VersionChanged: '2.13'
318
340
  StyleGuide: https://rspec.rubystyle.guide/#empty-line-after-let
319
341
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterHook
342
+ AllowConsecutiveOneLiners: true
320
343
 
321
344
  RSpec/EmptyLineAfterSubject:
322
345
  Description: Checks if there is an empty line after subject block.
@@ -607,10 +630,18 @@ RSpec/NestedGroups:
607
630
  Description: Checks for nested example groups.
608
631
  Enabled: true
609
632
  Max: 3
633
+ AllowedGroups: []
610
634
  VersionAdded: '1.7'
611
- VersionChanged: '1.10'
635
+ VersionChanged: '2.13'
612
636
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NestedGroups
613
637
 
638
+ RSpec/NoExpectationExample:
639
+ Description: Checks if an example contains any expectation.
640
+ Enabled: pending
641
+ Safe: false
642
+ VersionAdded: '2.13'
643
+ Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NoExpectationExample
644
+
614
645
  RSpec/NotToNot:
615
646
  Description: Checks for consistent method usage for negating expectations.
616
647
  Enabled: true
@@ -775,9 +806,10 @@ RSpec/VariableName:
775
806
  SupportedStyles:
776
807
  - snake_case
777
808
  - camelCase
809
+ AllowedPatterns: []
778
810
  IgnoredPatterns: []
779
811
  VersionAdded: '1.40'
780
- VersionChanged: '1.43'
812
+ VersionChanged: '2.13'
781
813
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VariableName
782
814
 
783
815
  RSpec/VerifiedDoubleReference:
@@ -834,6 +866,12 @@ RSpec/Capybara/FeatureMethods:
834
866
  VersionChanged: '2.0'
835
867
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/FeatureMethods
836
868
 
869
+ RSpec/Capybara/SpecificFinders:
870
+ Description: Checks if there is a more specific finder offered by Capybara.
871
+ Enabled: pending
872
+ VersionAdded: '2.13'
873
+ Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/SpecificFinders
874
+
837
875
  RSpec/Capybara/SpecificMatcher:
838
876
  Description: Checks for there is a more specific matcher offered by Capybara.
839
877
  Enabled: pending
@@ -0,0 +1,14 @@
1
+ #
2
+ # Configuration of obsolete/deprecated cops used by `ConfigObsoletion`.
3
+ #
4
+ # See: https://docs.rubocop.org/rubocop/extensions.html#config-obsoletions
5
+ #
6
+
7
+ # Cop parameters that have been changed
8
+ # Can be treated as a warning instead of a failure with `severity: warning`
9
+ changed_parameters:
10
+ - cops:
11
+ - RSpec/VariableName
12
+ parameters: IgnoredPatterns
13
+ alternative: AllowedPatterns
14
+ severity: warning
@@ -6,16 +6,15 @@ module RuboCop
6
6
  # Checks that left braces for adjacent single line lets are aligned.
7
7
  #
8
8
  # @example
9
+ # # bad
10
+ # let(:foobar) { blahblah }
11
+ # let(:baz) { bar }
12
+ # let(:a) { b }
9
13
  #
10
- # # bad
11
- # let(:foobar) { blahblah }
12
- # let(:baz) { bar }
13
- # let(:a) { b }
14
- #
15
- # # good
16
- # let(:foobar) { blahblah }
17
- # let(:baz) { bar }
18
- # let(:a) { b }
14
+ # # good
15
+ # let(:foobar) { blahblah }
16
+ # let(:baz) { bar }
17
+ # let(:a) { b }
19
18
  #
20
19
  class AlignLeftLetBrace < Base
21
20
  extend AutoCorrector
@@ -6,16 +6,15 @@ module RuboCop
6
6
  # Checks that right braces for adjacent single line lets are aligned.
7
7
  #
8
8
  # @example
9
+ # # bad
10
+ # let(:foobar) { blahblah }
11
+ # let(:baz) { bar }
12
+ # let(:a) { b }
9
13
  #
10
- # # bad
11
- # let(:foobar) { blahblah }
12
- # let(:baz) { bar }
13
- # let(:a) { b }
14
- #
15
- # # good
16
- # let(:foobar) { blahblah }
17
- # let(:baz) { bar }
18
- # let(:a) { b }
14
+ # # good
15
+ # let(:foobar) { blahblah }
16
+ # let(:baz) { bar }
17
+ # let(:a) { b }
19
18
  #
20
19
  class AlignRightLetBrace < Base
21
20
  extend AutoCorrector
@@ -22,6 +22,7 @@ module RuboCop
22
22
  # allow(my_instance).to receive(:foo)
23
23
  # end
24
24
  # end
25
+ #
25
26
  class AnyInstance < Base
26
27
  MSG = 'Avoid stubbing using `%<method>s`.'
27
28
  RESTRICT_ON_SEND = %i[
@@ -25,23 +25,29 @@ module RuboCop
25
25
  # some_method
26
26
  # test.run
27
27
  # end
28
+ #
28
29
  class AroundBlock < Base
29
30
  MSG_NO_ARG = 'Test object should be passed to around block.'
30
31
  MSG_UNUSED_ARG = 'You should call `%<arg>s.call` ' \
31
32
  'or `%<arg>s.run`.'
32
33
 
33
- # @!method hook(node)
34
- def_node_matcher :hook, <<-PATTERN
34
+ # @!method hook_block(node)
35
+ def_node_matcher :hook_block, <<-PATTERN
35
36
  (block (send nil? :around sym ?) (args $...) ...)
36
37
  PATTERN
37
38
 
39
+ # @!method hook_numblock(node)
40
+ def_node_matcher :hook_numblock, <<-PATTERN
41
+ (numblock (send nil? :around sym ?) ...)
42
+ PATTERN
43
+
38
44
  # @!method find_arg_usage(node)
39
45
  def_node_search :find_arg_usage, <<-PATTERN
40
46
  {(send $... {:call :run}) (send _ _ $...) (yield $...) (block-pass $...)}
41
47
  PATTERN
42
48
 
43
49
  def on_block(node)
44
- hook(node) do |(example_proxy)|
50
+ hook_block(node) do |(example_proxy)|
45
51
  if example_proxy.nil?
46
52
  add_no_arg_offense(node)
47
53
  else
@@ -50,6 +56,12 @@ module RuboCop
50
56
  end
51
57
  end
52
58
 
59
+ def on_numblock(node)
60
+ hook_numblock(node) do
61
+ check_for_numblock(node)
62
+ end
63
+ end
64
+
53
65
  private
54
66
 
55
67
  def add_no_arg_offense(node)
@@ -68,6 +80,17 @@ module RuboCop
68
80
  message: format(MSG_UNUSED_ARG, arg: name)
69
81
  )
70
82
  end
83
+
84
+ def check_for_numblock(block)
85
+ find_arg_usage(block) do |usage|
86
+ return if usage.include?(s(:lvar, :_1))
87
+ end
88
+
89
+ add_offense(
90
+ block.children.last,
91
+ message: format(MSG_UNUSED_ARG, arg: :_1)
92
+ )
93
+ end
71
94
  end
72
95
  end
73
96
  end
@@ -10,7 +10,6 @@ module RuboCop
10
10
  # cases it's better to specify what exactly is the expected value.
11
11
  #
12
12
  # @example
13
- #
14
13
  # # bad
15
14
  # expect(foo).to be
16
15
  #
@@ -10,7 +10,6 @@ module RuboCop
10
10
  # the `be` matcher is preferable as it is a more strict test.
11
11
  #
12
12
  # @example
13
- #
14
13
  # # bad
15
14
  # expect(foo).to eq(true)
16
15
  # expect(foo).to eq(false)
@@ -11,7 +11,6 @@ module RuboCop
11
11
  # preferable as it is a more strict test.
12
12
  #
13
13
  # @example
14
- #
15
14
  # # bad
16
15
  # expect(foo).to eql(1)
17
16
  # expect(foo).to eql(1.0)
@@ -23,6 +23,7 @@ module RuboCop
23
23
  # before(:each) { Widget.create }
24
24
  # after(:each) { Widget.delete_all }
25
25
  # end
26
+ #
26
27
  class BeforeAfterAll < Base
27
28
  MSG = 'Beware of using `%<hook>s` as it may cause state to leak ' \
28
29
  'between tests. If you are using `rspec-rails`, and ' \
@@ -14,14 +14,20 @@ module RuboCop
14
14
  # which ensures that preceding actions (like `click_link`) have
15
15
  # completed.
16
16
  #
17
+ # This cop does not support autocorrection in some cases.
18
+ #
17
19
  # @example
18
20
  # # bad
19
21
  # expect(current_path).to eq('/callback')
20
- # expect(page.current_path).to match(/widgets/)
21
22
  #
22
23
  # # good
23
- # expect(page).to have_current_path("/callback")
24
- # expect(page).to have_current_path(/widgets/)
24
+ # expect(page).to have_current_path('/callback')
25
+ #
26
+ # # bad (does not support autocorrection)
27
+ # expect(page.current_path).to match(variable)
28
+ #
29
+ # # good
30
+ # expect(page).to have_current_path('/callback')
25
31
  #
26
32
  class CurrentPathExpectation < Base
27
33
  extend AutoCorrector
@@ -40,6 +40,7 @@ module RuboCop
40
40
  # # ...
41
41
  # end
42
42
  # end
43
+ #
43
44
  class FeatureMethods < Base
44
45
  extend AutoCorrector
45
46
  include InsideExampleGroup
@@ -68,7 +69,7 @@ module RuboCop
68
69
  ...)
69
70
  PATTERN
70
71
 
71
- def on_block(node)
72
+ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
72
73
  return unless inside_example_group?(node)
73
74
 
74
75
  feature_method(node) do |send_node, match|