Skip to content

Commit

Permalink
Add test for anonymous module with private method
Browse files Browse the repository at this point in the history
This already passes on RuboCop AST 1.0.1 via
rubocop/rubocop-ast@12734b6,
but I think it's worth adding as an integration test anyway, and we can
also now drop the refinement-specific check added in
69700a5.
  • Loading branch information
eugeneius committed Oct 25, 2020
1 parent 69a0284 commit 84551d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rubocop/cop/layout/def_end_alignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def on_def(node)
alias on_defs on_def

def on_send(node)
return if !node.def_modifier? || node.method?(:using)
return unless node.def_modifier?

method_def = node.each_descendant(:def, :defs).first
expr = node.source_range
Expand Down
11 changes: 11 additions & 0 deletions spec/rubocop/cop/layout/def_end_alignment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ class << Hash
RUBY
end
end

context 'when including an anonymous module containing `private def`' do
it 'does not register an offense' do
expect_no_offenses(<<~RUBY)
include Module.new {
private def foo
end
}
RUBY
end
end
end

context 'when EnforcedStyleAlignWith is def' do
Expand Down

0 comments on commit 84551d1

Please sign in to comment.