rubocop-rspec-focused 0.0.3 → 0.1.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
  SHA1:
3
- metadata.gz: 467243310cd3d52aff8f74aed12c874517c29b84
4
- data.tar.gz: 3391ab4fbc27544bb4744aba8075cc5d6d04b36a
3
+ metadata.gz: 2b89542c8c8511884112810b0f23ce6df85267e5
4
+ data.tar.gz: 43b94b14aad5b8557454b63dd1f8674d4793e9c3
5
5
  SHA512:
6
- metadata.gz: dc0f3a9d7fe52ef7d82ea22fc4cfeeafd621e450e6972ca9d76e02324abec40c30377d1cd4c8f0e66e0ac8fd00ec1e3587c88fa6f042af31c9bcb384a10ce8ec
7
- data.tar.gz: f0a48cb5f67b5e57bb1f1202686aeba639bf5ea4691d70d06744bc2c5afd948d7f7591f5e72d317572694b8edd4436b935dd1f260cf5e38df4869f37f5948a74
6
+ metadata.gz: 49b97ab49781826e13321de2adb58d6c11e82d462eac434b844a7d0a81b02fdf44d45a6941032b5eac1273df6658ed6028de7fa510658aba7a5d7175cece3972
7
+ data.tar.gz: 1b79c2948a1c07f5716a90a9814b90a755d83cae987d2cde16fb1d1a6a1a6ed9b14d9e1eed829707936c65aade4c971a338b72f6b38fa9c982a405d0dd298bef
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "vendor/rubocop"]
2
+ path = vendor/rubocop
3
+ url = git://github.com/bbatsov/rubocop.git
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## master (unreleased)
2
2
 
3
+ ## 0.1.0
4
+
5
+ * Add autocorrect except for focus.
6
+
3
7
  ## 0.0.3
4
8
 
5
9
  * Fix error when block method has no arguments.
data/README.md CHANGED
@@ -78,3 +78,16 @@ Rspec/Focused:
78
78
  3. Commit your changes (`git commit -am 'Add some feature'`)
79
79
  4. Push to the branch (`git push origin my-new-feature`)
80
80
  5. Create a new Pull Request
81
+
82
+
83
+ For running the spec files, this project depends on RuboCop's spec helpers.
84
+ This means that in order to run the specs locally, you need a (shallow) clone
85
+ of the RuboCop repository:
86
+
87
+ ```bash
88
+ # Git 2.7 and below:
89
+ git submodule update --init vendor/rubocop
90
+
91
+ # Git 2.8 and above can use this instead:
92
+ git submodule update --init --depth 1 vendor/rubocop
93
+ ```
@@ -35,6 +35,19 @@ module RuboCop
35
35
  end
36
36
  end
37
37
 
38
+ def autocorrect(node)
39
+ method, _args, _body = *node
40
+ method_source = method.loc.selector.source
41
+ return if method_source == 'focus'
42
+
43
+ range = Parser::Source::Range.new(node.source_range.source_buffer,
44
+ method.loc.selector.begin_pos,
45
+ method.loc.selector.end_pos)
46
+ -> (corrector) do
47
+ corrector.replace(range, method_source[1..-1])
48
+ end
49
+ end
50
+
38
51
  private
39
52
 
40
53
  def focus_set_to_true?(metadata)
@@ -1,7 +1,7 @@
1
1
  module RuboCop
2
2
  module RSpec
3
3
  module Focused
4
- VERSION = '0.0.3'
4
+ VERSION = '0.1.0'
5
5
  end
6
6
  end
7
7
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "rubocop"
21
+ spec.add_runtime_dependency "rubocop", ">= 0.37"
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.6"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
@@ -15,6 +15,19 @@ RSpec.describe RuboCop::Cop::RSpec::Focused do
15
15
  end
16
16
  end
17
17
 
18
+ (described_class::FOCUSED_METHODS - [:focus]).each do |method|
19
+ it "autocorrects #{method}" do
20
+ source = ["#{method} 'does something' do", ' expect(foo).to be_empty', 'end']
21
+
22
+ expected_source = [
23
+ "#{method[1..-1]} 'does something' do", ' expect(foo).to be_empty', 'end'
24
+ ].join("\n")
25
+
26
+ autocorrected_source = autocorrect_source(cop, source)
27
+ expect(autocorrected_source).to eq(expected_source)
28
+ end
29
+ end
30
+
18
31
  it 'finds an example with focus: true' do
19
32
  inspect_source(cop, ['it "does something", foo: bar, focus: true do',
20
33
  ' expect(foo).to be_empty',
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,10 @@
1
- require File.join(
2
- Gem::Specification.find_by_name('rubocop').gem_dir,
3
- 'spec/support', 'cop_helper.rb'
4
- )
1
+ project_path = File.join(File.dirname(__FILE__), '..')
2
+ rubocop_path = File.join(project_path, 'vendor/rubocop')
3
+ unless File.directory?(rubocop_path)
4
+ raise "Can't run specs without a local RuboCop checkout. Look in the README."
5
+ end
6
+
7
+ require "#{rubocop_path}/spec/support/cop_helper.rb"
5
8
 
6
9
  Dir['spec/support/**/*.rb'].each { |f| require f.sub(/\Aspec\//, '') }
7
10
 
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.3
4
+ version: 0.1.0
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-03-09 00:00:00.000000000 Z
11
+ date: 2016-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.37'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.37'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -74,6 +74,7 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
+ - ".gitmodules"
77
78
  - ".rspec"
78
79
  - ".travis.yml"
79
80
  - CHANGELOG.md
@@ -107,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  version: '0'
108
109
  requirements: []
109
110
  rubyforge_project:
110
- rubygems_version: 2.2.2
111
+ rubygems_version: 2.4.8
111
112
  signing_key:
112
113
  specification_version: 4
113
114
  summary: RuboCop extension to find focused specs