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

add specs for Layout/RescueEnsureAlignment fix c8ab8d9 from #6254 #6771

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 22 additions & 0 deletions spec/rubocop/cop/layout/rescue_ensure_alignment_spec.rb
Expand Up @@ -364,6 +364,28 @@ def method2
RUBY
end

context 'rescue with assigned begin' do
it 'accepts variable-aligned rescue in or-assigned begin-end block' do
expect_no_offenses(<<-RUBY.strip_indent)
@bar ||= begin
expensive_method
rescue StandardError
fall_back
end
RUBY
end

it 'accepts variable-aligned rescue in assigned begin-end block' do
expect_no_offenses(<<-RUBY.strip_indent)
@bar = begin
expensive_method
rescue StandardError
fall_back
end
RUBY
end
end

context '>= Ruby 2.5', :ruby25 do
it 'accepts aligned rescue in do-end block' do
expect_no_offenses(<<-RUBY.strip_indent)
Expand Down