rubocop-rspec 1.14.0 → 1.15.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/config/default.yml +4 -0
- data/lib/rubocop-rspec.rb +1 -0
- data/lib/rubocop/cop/rspec/describe_symbol.rb +33 -0
- data/lib/rubocop/cop/rspec/overwriting_setup.rb +1 -1
- data/lib/rubocop/cop/rspec/scattered_let.rb +1 -1
- data/lib/rubocop/rspec/language/node_pattern.rb +5 -0
- data/lib/rubocop/rspec/version.rb +1 -1
- data/spec/rubocop/cop/rspec/describe_symbol_spec.rb +42 -0
- data/spec/rubocop/cop/rspec/overwriting_setup_spec.rb +5 -0
- data/spec/rubocop/cop/rspec/scattered_let_spec.rb +5 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05c5a02b8f251474055785a8e599fa2bbd66a5da
|
4
|
+
data.tar.gz: 4d34abb87f561cbe99dcd4df35d4d2e4b8eb1499
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55de6981f33d7f310a4290a1fc4578bb6d0ba905a2ce4ea86f966d025165cfd6d08d05f5198b56dcd207178724f574e6e046cb4af01be02a7e36662cfe792647
|
7
|
+
data.tar.gz: 73f5cdbc39ed5bc4aaa0d2fa8aa0769855b09f2d960ccf5078638582be79556109a491819a4253414a567a50baef1e66b6b737203998a57fad0cf2997c4446ca
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
## Master (Unreleased)
|
4
4
|
|
5
|
+
## 1.15.0 (2017-05-24)
|
6
|
+
|
7
|
+
* Add `RSpec/DescribeSymbol` cop. ([@tsigo][])
|
8
|
+
* Fix error when `RSpec/OverwritingSetup` and `RSpec/ScatteredLet` analyzed empty example groups. ([@backus][])
|
9
|
+
|
5
10
|
## 1.14.0 (2017-03-24)
|
6
11
|
|
7
12
|
* Add `RSpec/OverwritingSetup` cop. ([@Darhazer][])
|
@@ -206,3 +211,4 @@
|
|
206
211
|
[@redross]: https://github.com/redross
|
207
212
|
[@cfabianski]: https://github.com/cfabianski
|
208
213
|
[@dgollahon]: https://github.com/dgollahon
|
214
|
+
[@tsigo]: https://github.com/tsigo
|
data/config/default.yml
CHANGED
@@ -42,6 +42,10 @@ RSpec/DescribeMethod:
|
|
42
42
|
Description: Checks that the second argument to `describe` specifies a method.
|
43
43
|
Enabled: true
|
44
44
|
|
45
|
+
RSpec/DescribeSymbol:
|
46
|
+
Description: Avoid describing symbols.
|
47
|
+
Enabled: true
|
48
|
+
|
45
49
|
RSpec/IteratedExpectation:
|
46
50
|
Description: Check that `all` matcher is used instead of iterating over an array.
|
47
51
|
Enabled: true
|
data/lib/rubocop-rspec.rb
CHANGED
@@ -26,6 +26,7 @@ require 'rubocop/cop/rspec/be_eql'
|
|
26
26
|
require 'rubocop/cop/rspec/before_after_all'
|
27
27
|
require 'rubocop/cop/rspec/describe_class'
|
28
28
|
require 'rubocop/cop/rspec/describe_method'
|
29
|
+
require 'rubocop/cop/rspec/describe_symbol'
|
29
30
|
require 'rubocop/cop/rspec/described_class'
|
30
31
|
require 'rubocop/cop/rspec/empty_example_group'
|
31
32
|
require 'rubocop/cop/rspec/empty_line_after_final_let'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
# Avoid describing symbols.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# # bad
|
10
|
+
# describe :my_method do
|
11
|
+
# ...
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# describe '#my_method' do
|
16
|
+
# ...
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# See https://github.com/rspec/rspec-core/issues/1610
|
20
|
+
class DescribeSymbol < Cop
|
21
|
+
MSG = 'Avoid describing symbols.'.freeze
|
22
|
+
|
23
|
+
def_node_matcher :describe_symbol?, <<-PATTERN
|
24
|
+
(send {(const nil :RSpec) nil} :describe $sym ...)
|
25
|
+
PATTERN
|
26
|
+
|
27
|
+
def on_send(node)
|
28
|
+
describe_symbol?(node) { |match| add_offense(match, :expression) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -8,6 +8,11 @@ module RuboCop
|
|
8
8
|
extend RuboCop::NodePattern::Macros
|
9
9
|
|
10
10
|
def_node_matcher :example_group?, ExampleGroups::ALL.block_pattern
|
11
|
+
|
12
|
+
def_node_matcher :example_group_with_body?, <<-PATTERN
|
13
|
+
(block #{ExampleGroups::ALL.send_pattern} args [!nil])
|
14
|
+
PATTERN
|
15
|
+
|
11
16
|
def_node_matcher :example?, Examples::ALL.block_pattern
|
12
17
|
end
|
13
18
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
RSpec.describe RuboCop::Cop::RSpec::DescribeSymbol do
|
2
|
+
subject(:cop) { described_class.new }
|
3
|
+
|
4
|
+
it 'flags violations for `describe :symbol`' do
|
5
|
+
expect_violation(<<-RUBY)
|
6
|
+
describe(:some_method) { }
|
7
|
+
^^^^^^^^^^^^ Avoid describing symbols.
|
8
|
+
RUBY
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'flags violations for `describe :symbol` with multiple arguments' do
|
12
|
+
expect_violation(<<-RUBY)
|
13
|
+
describe(:some_method, "description") { }
|
14
|
+
^^^^^^^^^^^^ Avoid describing symbols.
|
15
|
+
RUBY
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'flags violations for `RSpec.describe :symbol`' do
|
19
|
+
expect_violation(<<-RUBY)
|
20
|
+
RSpec.describe(:some_method, "description") { }
|
21
|
+
^^^^^^^^^^^^ Avoid describing symbols.
|
22
|
+
RUBY
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'flags violations for a nested `describe`' do
|
26
|
+
expect_violation(<<-RUBY)
|
27
|
+
RSpec.describe Foo do
|
28
|
+
describe :to_s do
|
29
|
+
^^^^^ Avoid describing symbols.
|
30
|
+
end
|
31
|
+
end
|
32
|
+
RUBY
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'does not flag non-Symbol arguments' do
|
36
|
+
expect_no_violations('describe("#some_method") { }')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'does not flag `context :symbol`' do
|
40
|
+
expect_no_violations('context(:some_method) { }')
|
41
|
+
end
|
42
|
+
end
|
@@ -43,4 +43,9 @@ RSpec.describe RuboCop::Cop::RSpec::OverwritingSetup do
|
|
43
43
|
end
|
44
44
|
RUBY
|
45
45
|
end
|
46
|
+
|
47
|
+
it 'does not encounter an error when handling an empty describe' do
|
48
|
+
expect { inspect_source(cop, 'RSpec.describe(User) do end', 'a_spec.rb') }
|
49
|
+
.not_to raise_error
|
50
|
+
end
|
46
51
|
end
|
@@ -23,4 +23,9 @@ RSpec.describe RuboCop::Cop::RSpec::ScatteredLet do
|
|
23
23
|
end
|
24
24
|
RUBY
|
25
25
|
end
|
26
|
+
|
27
|
+
it 'does not encounter an error when handling an empty describe' do
|
28
|
+
expect { inspect_source(cop, 'RSpec.describe(User) do end', 'a_spec.rb') }
|
29
|
+
.not_to raise_error
|
30
|
+
end
|
26
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Backus
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-03-
|
13
|
+
date: 2017-03-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- lib/rubocop/cop/rspec/cop.rb
|
152
152
|
- lib/rubocop/cop/rspec/describe_class.rb
|
153
153
|
- lib/rubocop/cop/rspec/describe_method.rb
|
154
|
+
- lib/rubocop/cop/rspec/describe_symbol.rb
|
154
155
|
- lib/rubocop/cop/rspec/described_class.rb
|
155
156
|
- lib/rubocop/cop/rspec/empty_example_group.rb
|
156
157
|
- lib/rubocop/cop/rspec/empty_line_after_final_let.rb
|
@@ -212,6 +213,7 @@ files:
|
|
212
213
|
- spec/rubocop/cop/rspec/cop_spec.rb
|
213
214
|
- spec/rubocop/cop/rspec/describe_class_spec.rb
|
214
215
|
- spec/rubocop/cop/rspec/describe_method_spec.rb
|
216
|
+
- spec/rubocop/cop/rspec/describe_symbol_spec.rb
|
215
217
|
- spec/rubocop/cop/rspec/described_class_spec.rb
|
216
218
|
- spec/rubocop/cop/rspec/empty_example_group_spec.rb
|
217
219
|
- spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb
|
@@ -279,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
281
|
version: '0'
|
280
282
|
requirements: []
|
281
283
|
rubyforge_project:
|
282
|
-
rubygems_version: 2.
|
284
|
+
rubygems_version: 2.6.8
|
283
285
|
signing_key:
|
284
286
|
specification_version: 4
|
285
287
|
summary: Code style checking for RSpec files
|
@@ -295,6 +297,7 @@ test_files:
|
|
295
297
|
- spec/rubocop/cop/rspec/cop_spec.rb
|
296
298
|
- spec/rubocop/cop/rspec/describe_class_spec.rb
|
297
299
|
- spec/rubocop/cop/rspec/describe_method_spec.rb
|
300
|
+
- spec/rubocop/cop/rspec/describe_symbol_spec.rb
|
298
301
|
- spec/rubocop/cop/rspec/described_class_spec.rb
|
299
302
|
- spec/rubocop/cop/rspec/empty_example_group_spec.rb
|
300
303
|
- spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb
|