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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18d13e56c465ff7b44a3f971d20354f8317bafbe
4
- data.tar.gz: d59941e5b7c8e7167c42fc6cc954be23f3cb3c3e
3
+ metadata.gz: 77dc402b38ff0555f83ff46c05891ef6eabc19f2
4
+ data.tar.gz: 278fb1373ce6fb4b4c7ed2842b9c78acf46d3928
5
5
  SHA512:
6
- metadata.gz: 8138b5bf399d3cccd1a819c0f6c88309fe4d5e56d3eb6de5b0ead1a5d7c0148070c5d888a14c677e91ab73473419484d0a2295d1313d34edc1ff52d54756170c
7
- data.tar.gz: 6d28d20175cba0605b9a81caaad880af0dfa2f245b7e46c978edd3dae4a39061cfdb61f7317f73c77a3abf7d30445a7e769a8d60aba74ae6a7db101360360767
6
+ metadata.gz: 14f6217942dbdfd3bcc81c1e69a7799761b71e9b5894d3e280062e3b76d8d4a96b1b36b7d7a87cc4e013b0ec9f53cc94a4946e1ddd80444bc84df002af56eea2
7
+ data.tar.gz: 16a7cbe8f6fc304efb61fd76b587056bbe4ccc88ad241fe9abf118a3e219fd11ef7cae0d99ecca2698a9f9850becac8ac9a241663116949caf0733327f2b198d
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ rvm:
2
+ - 2.0.0
3
+ - 2.1.0
4
+ - 2.2.0
5
+ - rbx-2
6
+ - ruby-head
7
+
8
+ cache: bundler
9
+
10
+ bundler_args: --without dev --jobs=3
11
+
12
+ script: bundle exec rspec spec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## master (unreleased)
2
+
3
+ ## 0.0.2
4
+
5
+ * Support symbols passed as metadata, e.g:
6
+
7
+ describe 'foo', :focus do
8
+ end
9
+
1
10
  ## 0.0.1
2
11
 
3
12
  * Initial release.
data/README.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # rubocop-rspec-focused
2
2
 
3
- Cop for focused specs.
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
- it 'does something', focus: true do
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 .rubocop.yml:
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
- metadata && metadata.children.any? do |pair|
42
- pair == s(:pair, s(:sym, :focus), s(:true))
43
- end
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
@@ -1,7 +1,7 @@
1
1
  module RuboCop
2
2
  module RSpec
3
3
  module Focused
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
6
6
  end
7
7
  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.7"
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.1
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-02-17 00:00:00.000000000 Z
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.7'
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.7'
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