rubocop-rspec 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22b3b217241494fa4c167f2e15e07a19d360d5807d0278d58b0a5504c9268b8d
4
- data.tar.gz: 9111683fcaefd7c78675ce0549fa7e2a6a0c06a1b41e99b98472bd92b7459d03
3
+ metadata.gz: ec6f02aa20957826bdff135547211062ac19bdac9b260d2a008c45973944ff16
4
+ data.tar.gz: 57454e8f60b40062ad5da0ef9e4ce83c8539aea78d13d8412af24f43c01c2e1d
5
5
  SHA512:
6
- metadata.gz: 4276ab19bc2cbaad8649d0380b77be083d3afb21397ea63614b1a6275fc47b615c1f418d3ebbdf44e4bd674d3d663c896d74863798a1c2b208d06d5ac248e777
7
- data.tar.gz: 0b95a2233468bd4cd06596fe0a7c37d1f36e9481815cda16aa287eb8d479274e0aac813ceb2eede688853506fb023e7e469292713e4288271049573536ccbe94
6
+ metadata.gz: 51333677ad7c458afd2446b21c6e900c5f4ba597d2659cc2e389e5c9e223fe1885e54c8d427a8213519bd9176c0bfbc146910d6cd3c5dea7c9a69450ac34ce97
7
+ data.tar.gz: 5f6cffcb89273ddca1615907f8de6e619697c63c1255b630320b3852a9266aef4d260d295a6ee57ea1c91e862ad584750fac2784a2a536aea37887f829a14bd5
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## Master (Unreleased)
4
4
 
5
+ ## 2.6.0 (2021-11-08)
6
+
7
+ * Fix merging RSpec DSL configuration from third-party gems. ([@pirj][])
8
+ * Fix `RSpec/ExcessiveDocstringSpacing` false positive for multi-line indented strings. ([@G-Rath][])
9
+ * Fix `Include` configuration for sub-departments. ([@pirj][])
10
+ * Ignore heredocs in `RSpec/ExcessiveDocstringSpacing`. ([@G-Rath][])
11
+ * Stop `RSpec/ExampleWording` from trying to correct heredocs. ([@G-Rath][])
12
+ * Add autocorrect support for `RSpec/VariableDefinition`. ([@r7kamura][])
13
+
5
14
  ## 2.5.0 (2021-09-21)
6
15
 
7
16
  * Declare autocorrect as unsafe for `ExpectChange`. ([@francois-ferrandis][])
@@ -641,3 +650,4 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
641
650
  [@G-Rath]: https://github.com/G-Rath
642
651
  [@dswij]: https://github.com/dswij
643
652
  [@francois-ferrandis]: https://github.com/francois-ferrandis
653
+ [@r7kamura]: https://github.com/r7kamura
data/README.md CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  [![Join the chat at https://gitter.im/rubocop-rspec/Lobby](https://badges.gitter.im/rubocop-rspec/Lobby.svg)](https://gitter.im/rubocop-rspec/Lobby)
4
4
  [![Gem Version](https://badge.fury.io/rb/rubocop-rspec.svg)](https://rubygems.org/gems/rubocop-rspec)
5
- [![CircleCI](https://circleci.com/gh/rubocop/rubocop-rspec.svg?style=svg)](https://circleci.com/gh/rubocop/rubocop-rspec)
6
- [![Test Coverage](https://api.codeclimate.com/v1/badges/8ffaabf633c968c22bdd/test_coverage)](https://codeclimate.com/github/rubocop-hq/rubocop-rspec/test_coverage)
7
- [![Maintainability](https://api.codeclimate.com/v1/badges/8ffaabf633c968c22bdd/maintainability)](https://codeclimate.com/github/rubocop-hq/rubocop-rspec/maintainability)
5
+ ![CI](https://github.com/rubocop-hq/rubocop-rspec/workflows/CI/badge.svg)
8
6
 
9
7
  RSpec-specific analysis for your projects, as an extension to
10
8
  [RuboCop](https://github.com/rubocop/rubocop).
@@ -67,7 +65,7 @@ end
67
65
 
68
66
  ### Code Climate
69
67
 
70
- rubocop-rspec is available on Code Climate as part of the rubocop engine. [Learn More](https://codeclimate.com/changelog/55a433bbe30ba00852000fac).
68
+ rubocop-rspec is available on Code Climate as part of the rubocop engine. [Learn More](https://marketing.codeclimate.com/changelog/55a433bbe30ba00852000fac/).
71
69
 
72
70
  ## Documentation
73
71
 
data/config/default.yml CHANGED
@@ -1,11 +1,24 @@
1
1
  ---
2
2
  RSpec:
3
3
  Enabled: true
4
- Include:
4
+ Include: &1
5
5
  - "**/*_spec.rb"
6
6
  - "**/spec/**/*"
7
- Language:
7
+ Language: &2
8
+ inherit_mode:
9
+ merge:
10
+ - Expectations
11
+ - Helpers
12
+ - Hooks
13
+ - HookScopes
14
+ - Runners
15
+ - Subjects
8
16
  ExampleGroups:
17
+ inherit_mode:
18
+ merge:
19
+ - Regular
20
+ - Skipped
21
+ - Focused
9
22
  Regular:
10
23
  - describe
11
24
  - context
@@ -20,6 +33,12 @@ RSpec:
20
33
  - fcontext
21
34
  - ffeature
22
35
  Examples:
36
+ inherit_mode:
37
+ merge:
38
+ - Regular
39
+ - Skipped
40
+ - Focused
41
+ - Pending
23
42
  Regular:
24
43
  - it
25
44
  - specify
@@ -62,6 +81,10 @@ RSpec:
62
81
  - all
63
82
  - suite
64
83
  Includes:
84
+ inherit_mode:
85
+ merge:
86
+ - Examples
87
+ - Context
65
88
  Examples:
66
89
  - it_behaves_like
67
90
  - it_should_behave_like
@@ -73,6 +96,10 @@ RSpec:
73
96
  - to_not
74
97
  - not_to
75
98
  SharedGroups:
99
+ inherit_mode:
100
+ merge:
101
+ - Examples
102
+ - Context
76
103
  Examples:
77
104
  - shared_examples
78
105
  - shared_examples_for
@@ -718,6 +745,11 @@ RSpec/Yield:
718
745
  VersionAdded: '1.32'
719
746
  StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Yield
720
747
 
748
+ RSpec/Capybara:
749
+ Enabled: true
750
+ Include: *1
751
+ Language: *2
752
+
721
753
  RSpec/Capybara/CurrentPathExpectation:
722
754
  Description: Checks that no expectations are set on Capybara's `current_path`.
723
755
  Enabled: true
@@ -740,6 +772,11 @@ RSpec/Capybara/VisibilityMatcher:
740
772
  VersionChanged: '2.0'
741
773
  StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/VisibilityMatcher
742
774
 
775
+ RSpec/FactoryBot:
776
+ Enabled: true
777
+ Include: *1
778
+ Language: *2
779
+
743
780
  RSpec/FactoryBot/AttributeDefinedStatically:
744
781
  Description: Always declare attribute values as blocks.
745
782
  Enabled: true
@@ -779,6 +816,11 @@ RSpec/FactoryBot/FactoryClassName:
779
816
  VersionChanged: '2.0'
780
817
  StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/FactoryClassName
781
818
 
819
+ RSpec/Rails:
820
+ Enabled: true
821
+ Include: *1
822
+ Language: *2
823
+
782
824
  RSpec/Rails/AvoidSetupHook:
783
825
  Description: Checks that tests use RSpec `before` hook over Rails `setup` method.
784
826
  Enabled: pending
@@ -60,7 +60,10 @@ module RuboCop
60
60
 
61
61
  def add_wording_offense(node, message)
62
62
  docstring = docstring(node)
63
+
63
64
  add_offense(docstring, message: message) do |corrector|
65
+ next if node.heredoc?
66
+
64
67
  corrector.replace(docstring, replacement_text(node))
65
68
  end
66
69
  end
@@ -37,6 +37,8 @@ module RuboCop
37
37
 
38
38
  def on_send(node)
39
39
  example_description(node) do |description_node, message|
40
+ return if description_node.heredoc?
41
+
40
42
  text = text(message)
41
43
 
42
44
  return unless excessive_whitespace?(text)
@@ -49,7 +51,9 @@ module RuboCop
49
51
 
50
52
  # @param text [String]
51
53
  def excessive_whitespace?(text)
52
- text.start_with?(' ') || text.include?(' ') || text.end_with?(' ')
54
+ return true if text.start_with?(' ') || text.end_with?(' ')
55
+
56
+ text.match?(/[^\n ] +[^ ]/)
53
57
  end
54
58
 
55
59
  # @param text [String]
@@ -23,6 +23,7 @@ module RuboCop
23
23
  # subject('user') { create_user }
24
24
  # let('user_name') { 'Adam' }
25
25
  class VariableDefinition < Base
26
+ extend AutoCorrector
26
27
  include ConfigurableEnforcedStyle
27
28
  include Variable
28
29
 
@@ -30,14 +31,30 @@ module RuboCop
30
31
 
31
32
  def on_send(node)
32
33
  variable_definition?(node) do |variable|
33
- if style_violation?(variable)
34
- add_offense(variable, message: format(MSG, style: style))
34
+ next unless style_violation?(variable)
35
+
36
+ add_offense(
37
+ variable,
38
+ message: format(MSG, style: style)
39
+ ) do |corrector|
40
+ corrector.replace(variable, correct_variable(variable))
35
41
  end
36
42
  end
37
43
  end
38
44
 
39
45
  private
40
46
 
47
+ def correct_variable(variable)
48
+ case variable.type
49
+ when :dsym
50
+ variable.source[1..-1]
51
+ when :sym
52
+ variable.value.to_s.inspect
53
+ else
54
+ variable.value.to_sym.inspect
55
+ end
56
+ end
57
+
41
58
  def style_violation?(variable)
42
59
  style == :symbols && string?(variable) ||
43
60
  style == :strings && symbol?(variable)
@@ -5,6 +5,7 @@ module RuboCop
5
5
  # Shared behavior for aligning braces for single line lets
6
6
  class AlignLetBrace
7
7
  include RuboCop::RSpec::Language
8
+ include RuboCop::Cop::Util
8
9
 
9
10
  def initialize(root, token)
10
11
  @root = root
@@ -34,7 +35,7 @@ module RuboCop
34
35
  def let_group_for(let)
35
36
  adjacent_let_chunks.detect do |chunk|
36
37
  chunk.any? do |member|
37
- member == let && member.loc.line == let.loc.line
38
+ member == let && same_line?(member, let)
38
39
  end
39
40
  end
40
41
  end
@@ -7,6 +7,7 @@ module RuboCop
7
7
  # Builds a YAML config file from two config hashes
8
8
  class ConfigFormatter
9
9
  EXTENSION_ROOT_DEPARTMENT = %r{^(RSpec/)}.freeze
10
+ SUBDEPARTMENTS = %(RSpec/Capybara RSpec/FactoryBot RSpec/Rails)
10
11
  STYLE_GUIDE_BASE_URL = 'https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/'
11
12
 
12
13
  def initialize(config, descriptions)
@@ -24,6 +25,8 @@ module RuboCop
24
25
 
25
26
  def unified_config
26
27
  cops.each_with_object(config.dup) do |cop, unified|
28
+ next if SUBDEPARTMENTS.include?(cop)
29
+
27
30
  unified[cop] = config.fetch(cop)
28
31
  .merge(descriptions.fetch(cop))
29
32
  .merge('StyleGuide' => STYLE_GUIDE_BASE_URL + cop.sub('RSpec/', ''))
@@ -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.5.0'
7
+ STRING = '2.6.0'
8
8
  end
9
9
  end
10
10
  end
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.5.0
4
+ version: 2.6.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: 2021-09-21 00:00:00.000000000 Z
13
+ date: 2021-11-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -96,20 +96,6 @@ dependencies:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0.6'
99
- - !ruby/object:Gem::Dependency
100
- name: simplecov
101
- requirement: !ruby/object:Gem::Requirement
102
- requirements:
103
- - - "<"
104
- - !ruby/object:Gem::Version
105
- version: '0.18'
106
- type: :development
107
- prerelease: false
108
- version_requirements: !ruby/object:Gem::Requirement
109
- requirements:
110
- - - "<"
111
- - !ruby/object:Gem::Version
112
- version: '0.18'
113
99
  - !ruby/object:Gem::Dependency
114
100
  name: yard
115
101
  requirement: !ruby/object:Gem::Requirement
@@ -261,7 +247,7 @@ licenses:
261
247
  metadata:
262
248
  changelog_uri: https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md
263
249
  documentation_uri: https://docs.rubocop.org/rubocop-rspec/
264
- post_install_message:
250
+ post_install_message:
265
251
  rdoc_options: []
266
252
  require_paths:
267
253
  - lib
@@ -276,8 +262,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
262
  - !ruby/object:Gem::Version
277
263
  version: '0'
278
264
  requirements: []
279
- rubygems_version: 3.1.2
280
- signing_key:
265
+ rubygems_version: 3.2.29
266
+ signing_key:
281
267
  specification_version: 4
282
268
  summary: Code style checking for RSpec files
283
269
  test_files: []