rubocop-rspec-focused 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +12 -0
- data/CHANGELOG.md +9 -0
- data/README.md +35 -4
- data/lib/rubocop/cop/rspec/focused.rb +7 -4
- data/lib/rubocop/rspec/focused/version.rb +1 -1
- data/rubocop-rspec-focused.gemspec +1 -1
- data/spec/lib/rubocop/cop/rspec/focused_spec.rb +9 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77dc402b38ff0555f83ff46c05891ef6eabc19f2
|
4
|
+
data.tar.gz: 278fb1373ce6fb4b4c7ed2842b9c78acf46d3928
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14f6217942dbdfd3bcc81c1e69a7799761b71e9b5894d3e280062e3b76d8d4a96b1b36b7d7a87cc4e013b0ec9f53cc94a4946e1ddd80444bc84df002af56eea2
|
7
|
+
data.tar.gz: 16a7cbe8f6fc304efb61fd76b587056bbe4ccc88ad241fe9abf118a3e219fd11ef7cae0d99ecca2698a9f9850becac8ac9a241663116949caf0733327f2b198d
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
# rubocop-rspec-focused
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/lovewithfood/rubocop-rspec-focused.svg?branch=master)](https://travis-ci.org/lovewithfood/rubocop-rspec-focused)
|
4
|
+
|
5
|
+
RuboCop lint for focused specs.
|
6
|
+
|
7
|
+
It finds `focus: true` and the following method calls:
|
8
|
+
|
9
|
+
* `focus`
|
10
|
+
* `fexample`
|
11
|
+
* `fit`
|
12
|
+
* `fspecify`
|
13
|
+
* `fcontext`
|
14
|
+
* `fdescribe`
|
4
15
|
|
5
16
|
```ruby
|
6
17
|
# bad
|
@@ -8,7 +19,17 @@ fit 'does something' do
|
|
8
19
|
expect(foo).to be_empty
|
9
20
|
end
|
10
21
|
|
11
|
-
|
22
|
+
fdescribe Something do
|
23
|
+
it 'does something' do
|
24
|
+
expect(foo).to be_empty
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
specify 'does something', focus: true do
|
29
|
+
expect(foo).to be_empty
|
30
|
+
end
|
31
|
+
|
32
|
+
specify 'does something', :focus do
|
12
33
|
expect(foo).to be_empty
|
13
34
|
end
|
14
35
|
|
@@ -16,6 +37,16 @@ end
|
|
16
37
|
it 'does something' do
|
17
38
|
expect(foo).to be_empty
|
18
39
|
end
|
40
|
+
|
41
|
+
describe Something do
|
42
|
+
it 'does something' do
|
43
|
+
expect(foo).to be_empty
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
specify 'does something' do
|
48
|
+
expect(foo).to be_empty
|
49
|
+
end
|
19
50
|
```
|
20
51
|
|
21
52
|
## Installation
|
@@ -23,14 +54,14 @@ end
|
|
23
54
|
Add this line to your application's Gemfile:
|
24
55
|
|
25
56
|
```ruby
|
26
|
-
gem 'rubocop-rspec-focused'
|
57
|
+
gem 'rubocop-rspec-focused', require: false
|
27
58
|
```
|
28
59
|
|
29
60
|
And then execute:
|
30
61
|
|
31
62
|
$ bundle
|
32
63
|
|
33
|
-
And add this to
|
64
|
+
And add this to your `.rubocop.yml`:
|
34
65
|
|
35
66
|
```yml
|
36
67
|
require:
|
@@ -28,7 +28,7 @@ module RuboCop
|
|
28
28
|
|
29
29
|
def on_block(node)
|
30
30
|
method, _args, _body = *node
|
31
|
-
_receiver, method_name, _object, metadata = *method
|
31
|
+
_receiver, method_name, _object, *metadata = *method
|
32
32
|
|
33
33
|
if FOCUSED_METHODS.include?(method_name) || focus_set_to_true?(metadata)
|
34
34
|
add_offense(node, :expression, MESSAGE)
|
@@ -38,9 +38,12 @@ module RuboCop
|
|
38
38
|
private
|
39
39
|
|
40
40
|
def focus_set_to_true?(metadata)
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
return unless metadata
|
42
|
+
|
43
|
+
metadata.include?(s(:sym, :focus)) ||
|
44
|
+
metadata.last.children.any? do |pair|
|
45
|
+
pair == s(:pair, s(:sym, :focus), s(:true))
|
46
|
+
end
|
44
47
|
end
|
45
48
|
end
|
46
49
|
end
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "rubocop"
|
22
22
|
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.1.0"
|
26
26
|
end
|
@@ -23,4 +23,13 @@ RSpec.describe RuboCop::Cop::RSpec::Focused do
|
|
23
23
|
expect(cop.offenses.map(&:line).sort).to eq([1])
|
24
24
|
expect(cop.messages).to eq([described_class::MESSAGE])
|
25
25
|
end
|
26
|
+
|
27
|
+
it 'finds an example with :focus' do
|
28
|
+
inspect_source(cop, ['it "does something", :js, :focus do',
|
29
|
+
' expect(foo).to be_empty',
|
30
|
+
'end'])
|
31
|
+
expect(cop.offenses.size).to eq(1)
|
32
|
+
expect(cop.offenses.map(&:line).sort).to eq([1])
|
33
|
+
expect(cop.messages).to eq([described_class::MESSAGE])
|
34
|
+
end
|
26
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rspec-focused
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Love With Food, Hendy Tanata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.6'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
77
|
- ".rspec"
|
78
|
+
- ".travis.yml"
|
78
79
|
- CHANGELOG.md
|
79
80
|
- Gemfile
|
80
81
|
- LICENSE.txt
|