Skip to content

Commit

Permalink
Fix changed RuboCop methods (#438)
Browse files Browse the repository at this point in the history
* Upgrade dependency on RuboCop

* Work around removal of `Node#method_args` matcher

rubocop/rubocop@419bf0c

I'm not too sure about my "fix" of RepeatedExample.

* Work around changed `#inspect_source` method

rubocop/rubocop@9328215

* Work around changed `#autocorrect_source` method

rubocop/rubocop@3f91852

* Fix/ignore new RuboCop violations

- Lint/BooleanSymbol
- Lint/InterpolationCheck
- Naming/HeredocDelimiterCase
- Naming/HeredocDelimiterNaming
- Style/Encoding
  • Loading branch information
bquorning authored and backus committed Sep 14, 2017
1 parent 7fe393a commit c0d6fcb
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 21 deletions.
11 changes: 10 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Metrics/BlockLength:
- '**/*.rake'
- spec/**/*.rb

Style/FileName:
Naming/FileName:
Exclude:
- lib/rubocop-rspec.rb

Expand All @@ -21,6 +21,15 @@ Layout/MultilineMethodCallIndentation:
Layout/MultilineOperationIndentation:
EnforcedStyle: indented

Lint/BooleanSymbol:
Exclude:
- lib/rubocop/cop/rspec/expect_actual.rb
- lib/rubocop/cop/rspec/focus.rb

Lint/InterpolationCheck:
Exclude:
- spec/**/*.rb

RSpec/ExampleLength:
Max: 19

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/repeated_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def example_signature(example)
key_parts = [example.metadata, example.implementation]

if example.definition.method_name == :its
key_parts << example.definition.method_args
key_parts << example.definition.arguments
end

key_parts
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/rspec/hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def scope_name
end

def scope_argument
node.method_args.first
node.send_node.first_argument
end
end
end
Expand Down
8 changes: 3 additions & 5 deletions rubocop-rspec.gemspec
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# encoding: utf-8

$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
require 'rubocop/rspec/version'

Gem::Specification.new do |spec|
spec.name = 'rubocop-rspec'
spec.summary = 'Code style checking for RSpec files'
spec.description = <<-end_description
spec.description = <<-DESCRIPTION
Code style checking for RSpec files.
A plugin for the RuboCop code style enforcing & linting tool.
end_description
DESCRIPTION
spec.homepage = 'http://github.com/backus/rubocop-rspec'
spec.authors = ['John Backus', 'Ian MacLeod', 'Nils Gemeinhardt']
spec.email = [
Expand All @@ -34,7 +32,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^spec/})
spec.extra_rdoc_files = ['MIT-LICENSE.md', 'README.md']

spec.add_runtime_dependency 'rubocop', '>= 0.49.0'
spec.add_runtime_dependency 'rubocop', '>= 0.50.0'

spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec', '>= 3.4'
Expand Down
1 change: 0 additions & 1 deletion spec/rubocop/cop/rspec/expect_actual_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@

it 'ignores rspec-rails routing specs' do
inspect_source(
cop,
'expect(get: "/foo").to be_routeable',
'spec/routing/foo_spec.rb'
)
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/hook_argument_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# encoding: utf-8

RSpec.describe RuboCop::Cop::RSpec::HookArgument, :config do
subject(:cop) { described_class.new(config) }

Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/it_behaves_like_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# encoding: utf-8

RSpec.describe RuboCop::Cop::RSpec::ItBehavesLike, :config do
subject(:cop) { described_class.new(config) }

Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rspec/let_before_examples_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
end

it 'does not encounter an error when handling an empty describe' do
expect { inspect_source(cop, 'RSpec.describe(User) do end', 'a_spec.rb') }
expect { inspect_source('RSpec.describe(User) do end', 'a_spec.rb') }
.not_to raise_error
end
end
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rspec/multiple_expectations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
end

it 'generates a todo based on the worst violation' do
inspect_source(cop, <<-RUBY, 'spec/foo_spec.rb')
inspect_source(<<-RUBY, 'spec/foo_spec.rb')
describe Foo do
it 'uses expect twice' do
expect(foo).to eq(bar)
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rspec/multiple_subjects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
end
RUBY

expect(autocorrect_source(cop, source, 'example_spec.rb')).to eql(source)
expect(autocorrect_source(source, 'example_spec.rb')).to eql(source)
end

it 'does not flag shared example groups' do
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rspec/nested_groups_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MyThingy
let(:cop_config) { { 'MaxNesting' => '1' } }

it 'emits a deprecation warning' do
expect { inspect_source(cop, 'describe(Foo) { }', 'foo_spec.rb') }
expect { inspect_source('describe(Foo) { }', 'foo_spec.rb') }
.to output(
'Configuration key `MaxNesting` for RSpec/NestedGroups is ' \
"deprecated in favor of `Max`. Please use that instead.\n"
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rspec/overwriting_setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
end

it 'does not encounter an error when handling an empty describe' do
expect { inspect_source(cop, 'RSpec.describe(User) do end', 'a_spec.rb') }
expect { inspect_source('RSpec.describe(User) do end', 'a_spec.rb') }
.not_to raise_error
end
end
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rspec/scattered_let_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
end

it 'does not encounter an error when handling an empty describe' do
expect { inspect_source(cop, 'RSpec.describe(User) do end', 'a_spec.rb') }
expect { inspect_source('RSpec.describe(User) do end', 'a_spec.rb') }
.not_to raise_error
end
end
2 changes: 1 addition & 1 deletion spec/shared/autocorrect_behavior.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RSpec.shared_examples 'autocorrect' do |original, corrected|
it "autocorrects `#{original}` to `#{corrected}`" do
autocorrected = autocorrect_source(cop, original, 'spec/foo_spec.rb')
autocorrected = autocorrect_source(original, 'spec/foo_spec.rb')

expect(autocorrected).to eql(corrected)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/shared/detects_style_behavior.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RSpec.shared_examples 'detects style' do |source, style, filename: 'x_spec.rb'|
it 'generates a todo based on the detected style' do
inspect_source(cop, source, filename)
inspect_source(source, filename)

expect(cop.config_to_allow_offenses).to eq('EnforcedStyle' => style)
end
Expand Down

0 comments on commit c0d6fcb

Please sign in to comment.