rubocop-rspec 1.25.0 → 1.25.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/rubocop/cop/rspec/factory_bot/dynamic_attribute_defined_statically.rb +5 -8
- data/lib/rubocop/cop/rspec/pending.rb +4 -0
- data/lib/rubocop/rspec/version.rb +1 -1
- data/spec/rubocop/cop/rspec/factory_bot/dynamic_attribute_defined_statically_spec.rb +10 -0
- data/spec/rubocop/cop/rspec/pending_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3aa1fc65d7a5b5430ef4c5a88fa0daa56e09d330dd243225f3ef9b6332b076b3
|
4
|
+
data.tar.gz: 2e56f9dfd5b0b4f11ba040b032bd75ea366a10f15ac7255144971ddfd56027f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6066bc29073c219f495824ddce3c3b7d2237d1d06c28605ce536c46b2ec11d0240f05438d7ff8d4a03fde39d484816eb479122617cf411dcf91caba0b2d2cad
|
7
|
+
data.tar.gz: f1d974b0e62efee91acc48eef293fee4237ebb7ec3eb25eb210808e10432be9a010867818410e99b9986e518d24d237d77709c8acea41a35b3dab225412168d8
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
## Master (Unreleased)
|
4
4
|
|
5
|
+
## 1.25.1 (2018-04-10)
|
6
|
+
|
7
|
+
* Fix false positive in `RSpec/Pending` cop when pending is used as a method name. ([@Darhazer][])
|
8
|
+
* Fix `FactoryBot/DynamicAttributeDefinedStatically` false positive when using symbol proc argument for a sequence. ([@tdeo][])
|
9
|
+
|
5
10
|
## 1.25.0 (2018-04-07)
|
6
11
|
|
7
12
|
* Add `RSpec/SharedExamples` cop to enforce consistent usage of string to titleize shared examples. ([@anthony-robin][])
|
@@ -328,3 +333,4 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
328
333
|
[@jojos003]: https://github.com/jojos003
|
329
334
|
[@abrom]: https://github.com/abrom
|
330
335
|
[@patrickomatic]: https://github.com/patrickomatic
|
336
|
+
[@tdeo]: https://github.com/tdeo
|
@@ -31,14 +31,9 @@ module RuboCop
|
|
31
31
|
(block (send nil? {:factory :trait} ...) _ { (begin $...) $(send ...) } )
|
32
32
|
PATTERN
|
33
33
|
|
34
|
-
def_node_matcher :callback_with_symbol_proc?, <<-PATTERN
|
35
|
-
(send nil? {:before :after} sym (block_pass sym))
|
36
|
-
PATTERN
|
37
|
-
|
38
34
|
def on_block(node)
|
39
35
|
factory_attributes(node).to_a.flatten.each do |attribute|
|
40
|
-
next if
|
41
|
-
static?(attribute)
|
36
|
+
next if static_or_proc?(attribute)
|
42
37
|
add_offense(attribute, location: :expression)
|
43
38
|
end
|
44
39
|
end
|
@@ -55,8 +50,10 @@ module RuboCop
|
|
55
50
|
|
56
51
|
private
|
57
52
|
|
58
|
-
def
|
59
|
-
value_matcher(attribute).to_a.all?
|
53
|
+
def static_or_proc?(attribute)
|
54
|
+
value_matcher(attribute).to_a.all? do |value|
|
55
|
+
value.block_pass_type? || value.recursive_literal_or_const?
|
56
|
+
end
|
60
57
|
end
|
61
58
|
|
62
59
|
def value_hash_without_braces?(node)
|
@@ -43,8 +43,12 @@ module RuboCop
|
|
43
43
|
|
44
44
|
def_node_matcher :pending_block?, PENDING_EXAMPLES.send_pattern
|
45
45
|
|
46
|
+
def_node_matcher :rspec?, '(send {(const nil? :RSpec) nil?} ...)'
|
47
|
+
|
46
48
|
def on_send(node)
|
47
49
|
return unless pending_block?(node) || skipped_from_metadata?(node)
|
50
|
+
return unless rspec?(node)
|
51
|
+
|
48
52
|
add_offense(node, location: :expression)
|
49
53
|
end
|
50
54
|
|
@@ -87,6 +87,16 @@ RSpec.describe RuboCop::Cop::RSpec::FactoryBot::DynamicAttributeDefinedStaticall
|
|
87
87
|
RUBY
|
88
88
|
end
|
89
89
|
|
90
|
+
it 'accepts valid sequence definition' do
|
91
|
+
expect_no_offenses(<<-RUBY)
|
92
|
+
#{factory_bot}.define do
|
93
|
+
factory :post do
|
94
|
+
sequence :negative_numbers, &:-@
|
95
|
+
end
|
96
|
+
end
|
97
|
+
RUBY
|
98
|
+
end
|
99
|
+
|
90
100
|
bad = <<-RUBY
|
91
101
|
#{factory_bot}.define do
|
92
102
|
factory :post do
|
@@ -106,6 +106,14 @@ RSpec.describe RuboCop::Cop::RSpec::Pending do
|
|
106
106
|
RUBY
|
107
107
|
end
|
108
108
|
|
109
|
+
it 'flags pending examples when receiver is explicit' do
|
110
|
+
expect_offense(<<-RUBY)
|
111
|
+
RSpec.xit 'test' do
|
112
|
+
^^^^^^^^^^^^^^^^ Pending spec found.
|
113
|
+
end
|
114
|
+
RUBY
|
115
|
+
end
|
116
|
+
|
109
117
|
it 'does not flag describe' do
|
110
118
|
expect_no_offenses(<<-RUBY)
|
111
119
|
describe 'test' do; end
|
@@ -159,4 +167,10 @@ RSpec.describe RuboCop::Cop::RSpec::Pending do
|
|
159
167
|
example_group 'test' do; end
|
160
168
|
RUBY
|
161
169
|
end
|
170
|
+
|
171
|
+
it 'does not flag method called pending' do
|
172
|
+
expect_no_offenses(<<-RUBY)
|
173
|
+
subject { Project.pending }
|
174
|
+
RUBY
|
175
|
+
end
|
162
176
|
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.25.
|
4
|
+
version: 1.25.1
|
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: 2018-04-
|
13
|
+
date: 2018-04-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|