Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump version to v1.43.2 #1022

Merged
merged 3 commits into from Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,11 @@

## Master (Unreleased)

## 1.43.2 (2020-08-25)

* Fix `RSpec/FilePath` when checking a file with a shared example. ([@pirj][])
* Fix subject nesting detection in `RSpec/LeadingSubject`. ([@pirj][])

## 1.43.1 (2020-08-17)

* Fix `RSpec/FilePath` when checking a file defining e.g. an empty class. ([@bquorning][])
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/file_path.rb
Expand Up @@ -69,7 +69,7 @@ class FilePath < Base

def_node_search :routing_metadata?, '(pair (sym :type) (sym :routing))'

def on_top_level_group(node)
def on_top_level_example_group(node)
return unless top_level_groups.one?

const_described(node) do |send_node, described_class, arguments|
Expand Down
6 changes: 5 additions & 1 deletion lib/rubocop/cop/rspec/leading_subject.rb
Expand Up @@ -54,13 +54,17 @@ def check_previous_nodes(node)
private

def offending_node(node)
node.parent.each_child_node.find do |sibling|
parent(node).each_child_node.find do |sibling|
break if sibling.equal?(node)

yield sibling if offending?(sibling)
end
end

def parent(node)
node.each_ancestor(:block).first.body
end

def autocorrect(corrector, node, sibling)
RuboCop::RSpec::Corrector::MoveNode.new(
node, corrector, processed_source
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/rspec/top_level_group.rb
Expand Up @@ -16,7 +16,7 @@ def on_new_investigation
return unless root_node

top_level_groups.each do |node|
example_group?(node, &method(:on_top_level_example_group))
on_top_level_example_group(node) if example_group?(node)
on_top_level_group(node)
end
end
Expand All @@ -29,9 +29,9 @@ def top_level_groups
private

# Dummy methods to be overridden in the consumer
def on_top_level_example_group; end
def on_top_level_example_group(_node); end

def on_top_level_group; end
def on_top_level_group(_node); end

def top_level_group?(node)
top_level_groups.include?(node)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/rspec/version.rb
Expand Up @@ -4,7 +4,7 @@ module RuboCop
module RSpec
# Version information for the RSpec RuboCop plugin.
module Version
STRING = '1.43.1'
STRING = '1.43.2'
end
end
end
6 changes: 6 additions & 0 deletions spec/rubocop/cop/rspec/file_path_spec.rb
Expand Up @@ -64,6 +64,12 @@
RUBY
end

it 'ignores shared examples' do
expect_no_offenses(<<-RUBY, 'user.rb')
shared_examples_for 'foo' do; end
RUBY
end

it 'skips specs that do not describe a class / method' do
expect_no_offenses(<<-RUBY, 'some/class/spec.rb')
describe 'Test something' do; end
Expand Down
12 changes: 12 additions & 0 deletions spec/rubocop/cop/rspec/leading_subject_spec.rb
Expand Up @@ -269,4 +269,16 @@ def helper_method
end
RUBY
end

it 'ignores subject nested inside a block' do
expect_no_offenses(<<-RUBY)
RSpec.describe User do
let(:foo) { 'bar' }

it_behaves_like 'a good citizen' do
subject { described_class.new }
end
end
RUBY
end
end