rubocop-rspec 2.11.1 → 2.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +125 -81
  3. data/config/default.yml +59 -6
  4. data/lib/rubocop/cop/rspec/align_left_let_brace.rb +8 -9
  5. data/lib/rubocop/cop/rspec/align_right_let_brace.rb +8 -9
  6. data/lib/rubocop/cop/rspec/any_instance.rb +1 -0
  7. data/lib/rubocop/cop/rspec/around_block.rb +26 -3
  8. data/lib/rubocop/cop/rspec/be.rb +0 -1
  9. data/lib/rubocop/cop/rspec/be_eq.rb +0 -1
  10. data/lib/rubocop/cop/rspec/be_eql.rb +0 -1
  11. data/lib/rubocop/cop/rspec/before_after_all.rb +1 -0
  12. data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +9 -3
  13. data/lib/rubocop/cop/rspec/capybara/feature_methods.rb +2 -1
  14. data/lib/rubocop/cop/rspec/capybara/specific_finders.rb +86 -0
  15. data/lib/rubocop/cop/rspec/capybara/specific_matcher.rb +158 -0
  16. data/lib/rubocop/cop/rspec/capybara/visibility_matcher.rb +0 -1
  17. data/lib/rubocop/cop/rspec/change_by_zero.rb +67 -7
  18. data/lib/rubocop/cop/rspec/class_check.rb +101 -0
  19. data/lib/rubocop/cop/rspec/context_method.rb +2 -1
  20. data/lib/rubocop/cop/rspec/context_wording.rb +49 -18
  21. data/lib/rubocop/cop/rspec/describe_class.rb +1 -1
  22. data/lib/rubocop/cop/rspec/describe_method.rb +1 -0
  23. data/lib/rubocop/cop/rspec/described_class.rb +5 -15
  24. data/lib/rubocop/cop/rspec/dialect.rb +1 -0
  25. data/lib/rubocop/cop/rspec/empty_example_group.rb +19 -4
  26. data/lib/rubocop/cop/rspec/empty_hook.rb +4 -5
  27. data/lib/rubocop/cop/rspec/empty_line_after_example.rb +4 -9
  28. data/lib/rubocop/cop/rspec/empty_line_after_example_group.rb +1 -1
  29. data/lib/rubocop/cop/rspec/empty_line_after_final_let.rb +2 -1
  30. data/lib/rubocop/cop/rspec/empty_line_after_hook.rb +32 -2
  31. data/lib/rubocop/cop/rspec/empty_line_after_subject.rb +2 -1
  32. data/lib/rubocop/cop/rspec/example_length.rb +3 -2
  33. data/lib/rubocop/cop/rspec/example_without_description.rb +3 -2
  34. data/lib/rubocop/cop/rspec/example_wording.rb +2 -1
  35. data/lib/rubocop/cop/rspec/excessive_docstring_spacing.rb +1 -0
  36. data/lib/rubocop/cop/rspec/expect_actual.rb +5 -0
  37. data/lib/rubocop/cop/rspec/expect_change.rb +9 -9
  38. data/lib/rubocop/cop/rspec/expect_in_hook.rb +4 -1
  39. data/lib/rubocop/cop/rspec/expect_output.rb +1 -0
  40. data/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb +2 -1
  41. data/lib/rubocop/cop/rspec/factory_bot/create_list.rb +50 -13
  42. data/lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb +1 -0
  43. data/lib/rubocop/cop/rspec/factory_bot/syntax_methods.rb +1 -1
  44. data/lib/rubocop/cop/rspec/file_path.rb +8 -4
  45. data/lib/rubocop/cop/rspec/focus.rb +20 -4
  46. data/lib/rubocop/cop/rspec/hook_argument.rb +10 -5
  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 +1 -3
  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 +3 -2
  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/leaky_constant_declaration.rb +1 -1
  57. data/lib/rubocop/cop/rspec/let_before_examples.rb +7 -8
  58. data/lib/rubocop/cop/rspec/let_setup.rb +4 -4
  59. data/lib/rubocop/cop/rspec/message_chain.rb +1 -1
  60. data/lib/rubocop/cop/rspec/message_expectation.rb +1 -1
  61. data/lib/rubocop/cop/rspec/message_spies.rb +7 -1
  62. data/lib/rubocop/cop/rspec/missing_example_group_argument.rb +2 -1
  63. data/lib/rubocop/cop/rspec/mixin/css_selector.rb +99 -0
  64. data/lib/rubocop/cop/rspec/mixin/empty_line_separation.rb +13 -4
  65. data/lib/rubocop/cop/rspec/mixin/namespace.rb +23 -0
  66. data/lib/rubocop/cop/rspec/multiple_describes.rb +1 -0
  67. data/lib/rubocop/cop/rspec/multiple_expectations.rb +19 -3
  68. data/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb +1 -3
  69. data/lib/rubocop/cop/rspec/multiple_subjects.rb +17 -2
  70. data/lib/rubocop/cop/rspec/named_subject.rb +2 -1
  71. data/lib/rubocop/cop/rspec/nested_groups.rb +45 -25
  72. data/lib/rubocop/cop/rspec/no_expectation_example.rb +64 -0
  73. data/lib/rubocop/cop/rspec/not_to_not.rb +13 -1
  74. data/lib/rubocop/cop/rspec/overwriting_setup.rb +2 -1
  75. data/lib/rubocop/cop/rspec/pending.rb +1 -0
  76. data/lib/rubocop/cop/rspec/predicate_matcher.rb +2 -1
  77. data/lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb +1 -2
  78. data/lib/rubocop/cop/rspec/rails/have_http_status.rb +47 -0
  79. data/lib/rubocop/cop/rspec/receive_counts.rb +14 -15
  80. data/lib/rubocop/cop/rspec/receive_never.rb +4 -5
  81. data/lib/rubocop/cop/rspec/repeated_description.rb +25 -26
  82. data/lib/rubocop/cop/rspec/repeated_example.rb +1 -1
  83. data/lib/rubocop/cop/rspec/repeated_example_group_body.rb +28 -29
  84. data/lib/rubocop/cop/rspec/repeated_example_group_description.rb +28 -29
  85. data/lib/rubocop/cop/rspec/repeated_include_example.rb +32 -33
  86. data/lib/rubocop/cop/rspec/return_from_stub.rb +12 -12
  87. data/lib/rubocop/cop/rspec/scattered_let.rb +1 -5
  88. data/lib/rubocop/cop/rspec/scattered_setup.rb +2 -2
  89. data/lib/rubocop/cop/rspec/shared_context.rb +1 -1
  90. data/lib/rubocop/cop/rspec/stubbed_mock.rb +0 -1
  91. data/lib/rubocop/cop/rspec/subject_declaration.rb +0 -1
  92. data/lib/rubocop/cop/rspec/subject_stub.rb +2 -2
  93. data/lib/rubocop/cop/rspec/unspecified_exception.rb +15 -15
  94. data/lib/rubocop/cop/rspec/variable_definition.rb +1 -0
  95. data/lib/rubocop/cop/rspec/variable_name.rb +6 -7
  96. data/lib/rubocop/cop/rspec/verified_doubles.rb +1 -0
  97. data/lib/rubocop/cop/rspec/void_expect.rb +2 -1
  98. data/lib/rubocop/cop/rspec/yield.rb +3 -2
  99. data/lib/rubocop/cop/rspec_cops.rb +5 -0
  100. data/lib/rubocop/rspec/config_formatter.rb +14 -3
  101. data/lib/rubocop/rspec/inject.rb +1 -3
  102. data/lib/rubocop/rspec/language/node_pattern.rb +4 -0
  103. data/lib/rubocop/rspec/language.rb +6 -1
  104. data/lib/rubocop/rspec/node.rb +1 -1
  105. data/lib/rubocop/rspec/version.rb +1 -1
  106. data/lib/rubocop/rspec/wording.rb +2 -2
  107. data/lib/rubocop/rspec.rb +14 -0
  108. data/lib/rubocop-rspec.rb +3 -0
  109. metadata +12 -88
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 741b2b87f823e6fab2b693b917568362674a686183a1d00e11fbc24fecf8ae53
4
- data.tar.gz: '089bcc60333425fe0469071f12b52f92671a442274b179f50c716fce1e0a1064'
3
+ metadata.gz: 31d7e881e40be6a9b27f78f77789f1ecc5056bb073f5028a5c3dc0c6e1fe81ad
4
+ data.tar.gz: 7ad05e5a9ecfa1230aabfa54c7e6f9d7649f428017c405a9ed68d4da95218dd2
5
5
  SHA512:
6
- metadata.gz: 4f32ff6a813bcb2b427f13541c519d1da616cd051b7fbfbf4d8100fecf4e120e6626271623bd35833555061ef0c19e858934e07c6a8ed72a24cade03b1a59fee
7
- data.tar.gz: 29929728390c1ff9d6804c5babb614649966a60faccacc140f626e4eb78154eff39bb91fc38162fcfcdcdcbbb9593bdad8256f8471867e0dcb5b00abc047c544
6
+ metadata.gz: dfa4fca8f641da881b6014b91f5df8678af96c60e937339a81a64efd0bd87859ddc5876f977a995ae52a844e88bd53d46d50e0b37fd933b37e18da830991f245
7
+ data.tar.gz: f7779621a7c6fc6e33bf47b6823cfe7c4be08cc0f32ac02465cd4cbe35a1b8d4ed280a71c33f6fcfd7195a65191f68c9f9c13cdb0f8624a0a3e80be56af4dd50
data/CHANGELOG.md CHANGED
@@ -2,6 +2,44 @@
2
2
 
3
3
  ## Master (Unreleased)
4
4
 
5
+ ## 2.13.0 (2022-09-12)
6
+
7
+ * Fix `RSpec/FilePath` cop missing mismatched expanded namespace. ([@sl4vr][])
8
+ * Add new `AllowConsecutiveOneLiners` (default true) option for `Rspec/EmptyLineAfterHook` cop. ([@ngouy][])
9
+ * Add autocorrect support for `RSpec/EmptyExampleGroup`. ([@r7kamura][])
10
+ * Fix `RSpec/ChangeByZero` with compound expressions using `&` or `|` operators. ([@BrianHawley][])
11
+ * Add `RSpec/NoExpectationExample`. ([@r7kamura][])
12
+ * Add some expectation methods to default configuration. ([@r7kamura][])
13
+ * Fix a false positive for `RSpec/Capybara/SpecificMatcher`. ([@ydah][])
14
+ * Fix a false negative for `RSpec/Capybara/SpecificMatcher` for `have_field`. ([@ydah][])
15
+ * Fix a false positive for `RSpec/Capybara/SpecificMatcher` when may not have a `href` by `have_link`. ([@ydah][])
16
+ * Add `NegatedMatcher` configuration option to `RSpec/ChangeByZero`. ([@ydah][])
17
+ * Add new `RSpec/Capybara/SpecificFinders` cop. ([@ydah][])
18
+ * Add support for numblocks to `RSpec/AroundBlock`, `RSpec/EmptyLineAfterHook`, `RSpec/ExpectInHook`, `RSpec/HookArgument`, `RSpec/HooksBeforeExamples`, `RSpec/IteratedExpectation`, and `RSpec/NoExpectationExample`. ([@ydah][])
19
+ * Fix incorrect documentation URLs when using `rubocop --show-docs-url`. ([@r7kamura][])
20
+ * Add `AllowedGroups` configuration option to `RSpec/NestedGroups`. ([@ydah][])
21
+ * Deprecate `IgnoredPatterns` option in favor of the `AllowedPatterns` options. ([@ydah][])
22
+ * Add `AllowedPatterns` configuration option to `RSpec/ContextWording`. ([@ydah][])
23
+ * Add `RSpec/ClassCheck` cop. ([@r7kamura][])
24
+ * Fix a false positive for `RSpec/Capybara/SpecificMatcher` when pseudo-classes. ([@ydah][])
25
+ * Fix a false negative for `RSpec/SubjectStub` when the subject is declared with the `subject!` method and called by name. ([@eikes][])
26
+ * Support `Array.new(n)` on `RSpec/FactoryBot/CreateList` cop. ([@r7kamura][])
27
+
28
+ ## 2.12.1 (2022-07-03)
29
+
30
+ * Fix a false positive for `RSpec/Capybara/SpecificMatcher`. ([@ydah][])
31
+
32
+ ## 2.12.0 (2022-07-02)
33
+
34
+ * Fix incorrect path suggested by `RSpec/FilePath` cop when second argument contains spaces. ([@tejasbubane][])
35
+ * Fix autocorrect for EmptyLineSeparation. ([@johnny-miyake][])
36
+ * Add new `RSpec/Capybara/SpecificMatcher` cop. ([@ydah][])
37
+ * Fixed false offense detection in `FactoryBot/CreateList` when a n.times block is including method calls in the factory create arguments. ([@ngouy][])
38
+ * Fix error in `RSpec/RSpec/FactoryBot/CreateList` cop for empty block. ([@tejasbubane][])
39
+ * Update `RSpec/MultipleExpectations` cop documentation with examples of aggregate_failures use. ([@edgibbs][])
40
+ * Declare autocorrect as unsafe for `RSpec/VerifiedDoubleReference`. ([@Drowze][])
41
+ * Add new `RSpec/Rails/HaveHttpStatus` cop. ([@akiomik][])
42
+
5
43
  ## 2.11.1 (2022-05-18)
6
44
 
7
45
  * Fix a regression in `RSpec/ExpectChange` flagging chained method calls. ([@pirj][])
@@ -588,109 +626,115 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
588
626
  * Split `UnitSpecNaming` cop into `RSpecDescribeClass`, `RSpecDescribeMethod` and `RSpecFileName` and enabled them all by default. ([@geniou][])
589
627
  * Add `RSpecExampleWording` cop to prevent to use of should at the beginning of the spec description. ([@geniou][])
590
628
  * Fix `RSpecFileName` cop for non-class specs. ([@geniou][])
591
- * Adapt `RSpecFileName` cop to commen naming convention and skip spec with multiple top level describes. ([@geniou][])
629
+ * Adapt `RSpecFileName` cop to common naming convention and skip spec with multiple top level describes. ([@geniou][])
592
630
  * Add `RSpecMultipleDescribes` cop to check for multiple top level describes. ([@geniou][])
593
631
  * Add `RSpecDescribedClass` to promote the use of `described_class`. ([@geniou][])
594
632
  * Add `RSpecInstanceVariable` cop to check for the usage of instance variables. ([@geniou][])
595
633
 
596
- <!-- Contributors -->
634
+ <!-- Contributors (alphabetically) -->
597
635
 
636
+ [@abrom]: https://github.com/abrom
637
+ [@ahukkanen]: https://github.com/ahukkanen
638
+ [@akiomik]: https://github.com/akiomik
639
+ [@AlexWayfer]: https://github.com/AlexWayfer
640
+ [@andrykonchin]: https://github.com/andrykonchin
598
641
  [@andyw8]: https://github.com/andyw8
642
+ [@anthony-robin]: https://github.com/anthony-robin
643
+ [@aried3r]: https://github.com/aried3r
644
+ [@baberthal]: https://github.com/baberthal
599
645
  [@backus]: https://github.com/backus
646
+ [@biinari]: https://github.com/biinari
647
+ [@bmorrall]: https://github.com/bmorrall
600
648
  [@bquorning]: https://github.com/bquorning
649
+ [@BrentWheeldon]: https://github.com/BrentWheeldon
650
+ [@BrianHawley]: https://github.com/BrianHawley
651
+ [@cfabianski]: https://github.com/cfabianski
652
+ [@clupprich]: https://github.com/clupprich
653
+ [@composerinteralia]: https://github.com/composerinteralia
654
+ [@Darhazer]: https://github.com/Darhazer
655
+ [@daveworth]: https://github.com/daveworth
656
+ [@dduugg]: https://github.com/dduugg
601
657
  [@deivid-rodriguez]: https://github.com/deivid-rodriguez
658
+ [@dgollahon]: https://github.com/dgollahon
659
+ [@Drowze]: https://github.com/Drowze
660
+ [@dswij]: https://github.com/dswij
661
+ [@dvandersluis]: https://github.com/dvandersluis
662
+ [@edgibbs]: https://github.com/edgibbs
663
+ [@eikes]: https://github.com/eikes
664
+ [@eitoball]: https://github.com/eitoball
665
+ [@elebow]: https://github.com/elebow
666
+ [@EliseFitz15]: https://github.com/EliseFitz15
667
+ [@elliterate]: https://github.com/elliterate
668
+ [@foton]: https://github.com/foton
669
+ [@francois-ferrandis]: https://github.com/francois-ferrandis
670
+ [@G-Rath]: https://github.com/G-Rath
602
671
  [@geniou]: https://github.com/geniou
672
+ [@gsamokovarov]: https://github.com/gsamokovarov
673
+ [@harry-graham]: https://github.com/harry-graham
674
+ [@harrylewis]: https://github.com/harrylewis
675
+ [@hosamaly]: https://github.com/hosamaly
603
676
  [@jaredbeck]: https://github.com/jaredbeck
604
- [@jawshooah]: https://github.com/jawshooah
605
- [@nevir]: https://github.com/nevir
606
- [@nijikon]: https://github.com/nijikon
607
- [@pstengel]: https://github.com/pstengel
608
- [@miguelfteixeira]: https://github.com/miguelfteixeira
609
- [@mlarraz]: https://github.com/mlarraz
610
- [@renanborgescampos]: https://github.com/renanborgescampos
611
677
  [@jaredmoody]: https://github.com/jaredmoody
612
- [@baberthal]: https://github.com/baberthal
613
678
  [@jeffreyc]: https://github.com/jeffreyc
614
- [@clupprich]: https://github.com/clupprich
615
- [@onk]: https://github.com/onk
616
- [@Darhazer]: https://github.com/Darhazer
617
- [@redross]: https://github.com/redross
618
- [@cfabianski]: https://github.com/cfabianski
619
- [@dgollahon]: https://github.com/dgollahon
620
- [@rspeicher]: https://github.com/rspeicher
621
- [@jonatas]: https://github.com/jonatas
622
- [@pocke]: https://github.com/pocke
623
- [@bmorrall]: https://github.com/bmorrall
624
- [@zverok]: https://github.com/zverok
625
- [@timrogers]: https://github.com/timrogers
626
- [@yevhene]: https://github.com/yevhene
627
- [@walf443]: https://github.com/walf443
628
- [@pirj]: https://github.com/pirj
629
- [@telmofcosta]: https://github.com/telmofcosta
630
- [@EliseFitz15]: https://github.com/EliseFitz15
631
- [@anthony-robin]: https://github.com/anthony-robin
679
+ [@jfragoulis]: https://github.com/jfragoulis
680
+ [@johnny-miyake]: https://github.com/johnny-miyake
632
681
  [@jojos003]: https://github.com/jojos003
633
- [@abrom]: https://github.com/abrom
634
- [@patrickomatic]: https://github.com/patrickomatic
635
- [@tdeo]: https://github.com/tdeo
636
- [@composerinteralia]: https://github.com/composerinteralia
637
- [@seanpdoyle]: https://github.com/seanpdoyle
638
- [@vzvu3k6k]: https://github.com/vzvu3k6k
639
- [@BrentWheeldon]: https://github.com/BrentWheeldon
640
- [@daveworth]: https://github.com/daveworth
641
- [@RST-J]: https://github.com/RST-J
642
- [@ypresto]: https://github.com/ypresto
682
+ [@jonatas]: https://github.com/jonatas
683
+ [@jtannas]: https://github.com/jtannas
684
+ [@kellysutton]: https://github.com/kellysutton
685
+ [@koic]: https://github.com/koic
686
+ [@lazycoder9]: https://github.com/lazycoder9
687
+ [@leoarnold]: https://github.com/leoarnold
688
+ [@lokhi]: https://github.com/lokhi
689
+ [@luke-hill]: https://github.com/luke-hill
690
+ [@M-Yamashita01]: https://github.com/M-Yamashita01
691
+ [@miguelfteixeira]: https://github.com/miguelfteixeira
643
692
  [@mkenyon]: https://github.com/mkenyon
644
- [@gsamokovarov]: https://github.com/gsamokovarov
645
- [@schmijos]: https://github.com/schmijos
646
- [@foton]: https://github.com/foton
693
+ [@mkrawc]: https://github.com/mkrawc
694
+ [@mlarraz]: https://github.com/mlarraz
695
+ [@mockdeep]: https://github.com/mockdeep
696
+ [@MothOnMars]: https://github.com/MothOnMars
647
697
  [@nc-holodakg]: https://github.com/nc-holodakg
648
- [@onumis]: https://github.com/onumis
698
+ [@nevir]: https://github.com/nevir
699
+ [@ngouy]: https://github.com/ngouy
649
700
  [@nickcampbell18]: https://github.com/nickcampbell18
701
+ [@nijikon]: https://github.com/nijikon
702
+ [@onk]: https://github.com/onk
703
+ [@onumis]: https://github.com/onumis
704
+ [@oshiro3]: https://github.com/oshiro3
705
+ [@patrickomatic]: https://github.com/patrickomatic
706
+ [@paydaylight]: https://github.com/paydaylight
707
+ [@PhilCoggins]: https://github.com/PhilCoggins
708
+ [@pirj]: https://github.com/pirj
709
+ [@pocke]: https://github.com/pocke
710
+ [@pstengel]: https://github.com/pstengel
650
711
  [@QQism]: https://github.com/QQism
651
- [@kellysutton]: https://github.com/kellysutton
652
- [@mkrawc]: https://github.com/mkrawc
653
- [@jfragoulis]: https://github.com/jfragoulis
654
- [@ybiquitous]: https://github.com/ybiquitous
655
- [@dduugg]: https://github.com/dduugg
656
- [@lazycoder9]: https://github.com/lazycoder9
657
- [@elebow]: https://github.com/elebow
658
- [@eitoball]: https://github.com/eitoball
659
- [@aried3r]: https://github.com/aried3r
660
- [@AlexWayfer]: https://github.com/AlexWayfer
661
- [@tejasbubane]: https://github.com/tejasbubane
662
- [@twalpole]: https://github.com/twalpole
663
- [@zdennis]: https://github.com/zdennis
712
+ [@r7kamura]: https://github.com/r7kamura
713
+ [@Rafix02]: https://github.com/Rafix02
714
+ [@redross]: https://github.com/redross
715
+ [@renanborgescampos]: https://github.com/renanborgescampos
664
716
  [@robotdana]: https://github.com/robotdana
665
717
  [@rolfschmidt]: https://github.com/rolfschmidt
666
- [@andrykonchin]: https://github.com/andrykonchin
667
- [@harrylewis]: https://github.com/harrylewis
668
- [@elliterate]: https://github.com/elliterate
669
- [@jtannas]: https://github.com/jtannas
670
- [@mockdeep]: https://github.com/mockdeep
671
- [@biinari]: https://github.com/biinari
672
- [@koic]: https://github.com/koic
673
- [@Rafix02]: https://github.com/Rafix02
674
- [@PhilCoggins]: https://github.com/PhilCoggins
718
+ [@rrosenblum]: https://github.com/rrosenblum
719
+ [@rspeicher]: https://github.com/rspeicher
720
+ [@RST-J]: https://github.com/RST-J
721
+ [@schmijos]: https://github.com/schmijos
722
+ [@seanpdoyle]: https://github.com/seanpdoyle
675
723
  [@sl4vr]: https://github.com/sl4vr
676
- [@ahukkanen]: https://github.com/ahukkanen
677
- [@dvandersluis]: https://github.com/dvandersluis
678
- [@hosamaly]: https://github.com/hosamaly
679
724
  [@stephannv]: https://github.com/stephannv
725
+ [@t3h2mas]: https://github.com/t3h2mas
726
+ [@tdeo]: https://github.com/tdeo
727
+ [@tejasbubane]: https://github.com/tejasbubane
728
+ [@telmofcosta]: https://github.com/telmofcosta
680
729
  [@Tietew]: https://github.com/Tietew
681
- [@rrosenblum]: https://github.com/rrosenblum
682
- [@paydaylight]: https://github.com/paydaylight
730
+ [@timrogers]: https://github.com/timrogers
683
731
  [@topalovic]: https://github.com/topalovic
684
- [@lokhi]: https://github.com/lokhi
685
- [@MothOnMars]: https://github.com/MothOnMars
686
- [@G-Rath]: https://github.com/G-Rath
687
- [@dswij]: https://github.com/dswij
688
- [@francois-ferrandis]: https://github.com/francois-ferrandis
689
- [@r7kamura]: https://github.com/r7kamura
690
- [@leoarnold]: https://github.com/leoarnold
691
- [@harry-graham]: https://github.com/harry-graham
692
- [@oshiro3]: https://github.com/oshiro3
732
+ [@twalpole]: https://github.com/twalpole
733
+ [@vzvu3k6k]: https://github.com/vzvu3k6k
734
+ [@walf443]: https://github.com/walf443
735
+ [@ybiquitous]: https://github.com/ybiquitous
693
736
  [@ydah]: https://github.com/ydah
694
- [@t3h2mas]: https://github.com/t3h2mas
695
- [@M-Yamashita01]: https://github.com/M-Yamashita01
696
- [@luke-hill]: https://github.com/luke-hill
737
+ [@yevhene]: https://github.com/yevhene
738
+ [@ypresto]: https://github.com/ypresto
739
+ [@zdennis]: https://github.com/zdennis
740
+ [@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,19 +806,22 @@ 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:
784
816
  Description: Checks for consistent verified double reference style.
785
817
  Enabled: pending
818
+ SafeAutoCorrect: false
786
819
  EnforcedStyle: constant
787
820
  SupportedStyles:
788
821
  - constant
789
822
  - string
790
823
  VersionAdded: 2.10.0
824
+ VersionChanged: '2.12'
791
825
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VerifiedDoubleReference
792
826
 
793
827
  RSpec/VerifiedDoubles:
@@ -832,6 +866,18 @@ RSpec/Capybara/FeatureMethods:
832
866
  VersionChanged: '2.0'
833
867
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/FeatureMethods
834
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
+
875
+ RSpec/Capybara/SpecificMatcher:
876
+ Description: Checks for there is a more specific matcher offered by Capybara.
877
+ Enabled: pending
878
+ VersionAdded: '2.12'
879
+ Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/SpecificMatcher
880
+
835
881
  RSpec/Capybara/VisibilityMatcher:
836
882
  Description: Checks for boolean visibility in Capybara finders.
837
883
  Enabled: true
@@ -901,6 +947,13 @@ RSpec/Rails/AvoidSetupHook:
901
947
  VersionAdded: '2.4'
902
948
  Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/AvoidSetupHook
903
949
 
950
+ RSpec/Rails/HaveHttpStatus:
951
+ Description: Checks that tests use `have_http_status` instead of equality matchers.
952
+ Enabled: pending
953
+ SafeAutoCorrect: false
954
+ VersionAdded: '2.12'
955
+ Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HaveHttpStatus
956
+
904
957
  RSpec/Rails/HttpStatus:
905
958
  Description: Enforces use of symbolic or numeric value to describe HTTP status.
906
959
  Enabled: true
@@ -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|