Skip to content

Commit

Permalink
[Fix #6603] Add an extra test to RescueEnsureAlignment (#6606)
Browse files Browse the repository at this point in the history
Add a test to demonstrate the correct styles of a begin-rescue as the
RHS of an assignment.
  • Loading branch information
jaredbeck authored and bbatsov committed Mar 17, 2019
1 parent 6aff4c8 commit e1eb1f9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions spec/rubocop/cop/layout/rescue_ensure_alignment_spec.rb
Expand Up @@ -26,6 +26,40 @@
end
RUBY
end

context 'as RHS of assignment' do
it 'accepts multi-line, aligned' do
expect_no_offenses(<<-RUBY.strip_indent)
x ||= begin
1
rescue
2
end
RUBY
end

it 'accepts multi-line, indented' do
expect_no_offenses(<<-RUBY.strip_indent)
x ||=
begin
1
rescue
2
end
RUBY
end

it 'registers offense for incorrect alignment' do
expect_offense(<<-RUBY.strip_indent)
x ||= begin
1
rescue
^^^^^^ `rescue` at 3, 0 is not aligned with `begin` at 1, 6.
2
end
RUBY
end
end
end

context 'rescue with def' do
Expand Down

0 comments on commit e1eb1f9

Please sign in to comment.