diff --git a/.gitignore b/.gitignore index 831f386c6..f9bdfe523 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,5 @@ pkg # For rubinius: #*.rbc + +/vendor diff --git a/.travis.yml b/.travis.yml index 3a5022048..e2f286f01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,8 @@ matrix: allow_failures: - rvm: ruby-head - rvm: rbx-2 -before_install: gem update --remote bundler +before_install: + - gem update --remote bundler + - git clone --depth 1 git://github.com/bbatsov/rubocop.git vendor/rubocop script: - bundle exec rake diff --git a/README.md b/README.md index 534003e5b..6b47d3d58 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,22 @@ RSpec/FilePath: ``` +## Contributing + +1. Fork it +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create new Pull Request + +For running the spec files, this project depends on RuboCop's spec helpers. +This means that in order to run the specs locally, you need a (shallow) clone +of the RuboCop repository: + +```bash +git clone --depth 1 git://github.com/bbatsov/rubocop.git vendor/rubocop +``` + ## License `rubocop-rspec` is MIT licensed. [See the accompanying file](MIT-LICENSE.md) for diff --git a/lib/rubocop/cop/rspec/described_class.rb b/lib/rubocop/cop/rspec/described_class.rb index 9c8675a71..a136b41d8 100644 --- a/lib/rubocop/cop/rspec/described_class.rb +++ b/lib/rubocop/cop/rspec/described_class.rb @@ -34,7 +34,7 @@ def on_block(node) end def autocorrect(node) - @corrections << lambda do |corrector| + lambda do |corrector| corrector.replace(node.loc.expression, 'described_class') end end diff --git a/lib/rubocop/cop/rspec/example_wording.rb b/lib/rubocop/cop/rspec/example_wording.rb index 56c6e9884..983cfdb6b 100644 --- a/lib/rubocop/cop/rspec/example_wording.rb +++ b/lib/rubocop/cop/rspec/example_wording.rb @@ -21,7 +21,7 @@ class ExampleWording < Cop MSG = 'Do not use should when describing your tests.' def on_block(node) # rubocop:disable Metrics/AbcSize - method, _, _ = *node + method, = *node _, method_name, *args = *method return unless method_name == :it @@ -38,7 +38,7 @@ def on_block(node) # rubocop:disable Metrics/AbcSize end def autocorrect(range) - @corrections << lambda do |corrector| + lambda do |corrector| corrector.replace(range, corrected_message(range)) end end diff --git a/rubocop-rspec.gemspec b/rubocop-rspec.gemspec index fb3953cf6..c2432731f 100644 --- a/rubocop-rspec.gemspec +++ b/rubocop-rspec.gemspec @@ -27,10 +27,10 @@ Gem::Specification.new do |spec| 'Gemfile', 'Rakefile' ] - spec.test_files = spec.files.grep(/^spec\//) + spec.test_files = spec.files.grep(%r{^spec/}) spec.extra_rdoc_files = ['MIT-LICENSE.md', 'README.md'] - spec.add_development_dependency('rubocop', '~> 0.24') + spec.add_development_dependency('rubocop', '~> 0.31') spec.add_development_dependency('rake', '~> 10.1') spec.add_development_dependency('rspec', '~> 3.0') spec.add_development_dependency('simplecov', '~> 0.8') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 479de6ad5..770bdb376 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,8 +2,11 @@ require 'rubocop' -rubocop_gem_path = Gem::Specification.find_by_name('rubocop').gem_dir -Dir["#{rubocop_gem_path}/spec/support/**/*.rb"].each { |f| require f } +rubocop_path = File.join(File.dirname(__FILE__), '../vendor/rubocop') +unless File.directory?(rubocop_path) + fail "Can't run specs without a local RuboCop checkout. Look in the README." +end +Dir["#{rubocop_path}/spec/support/**/*.rb"].each { |f| require f } RSpec.configure do |config| config.order = :random diff --git a/vendor/.gitkeep b/vendor/.gitkeep new file mode 100644 index 000000000..e69de29bb