Skip to content

Commit

Permalink
Convert more examples to expect_correction
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Krizhanovski committed Feb 16, 2019
1 parent 937d098 commit 6834afe
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 518 deletions.
232 changes: 25 additions & 207 deletions spec/rubocop/cop/layout/rescue_ensure_alignment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,8 @@
error
end
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
begin
something
rescue
error
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
begin
something
rescue
Expand All @@ -48,18 +38,8 @@ def test
error
end
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
def test
something
rescue
error
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
def test
something
rescue
Expand All @@ -79,18 +59,8 @@ def Test.test
error
end
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
def Test.test
something
rescue
error
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
def Test.test
something
rescue
Expand All @@ -110,18 +80,8 @@ class C
error
end
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
class C
something
rescue
error
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
class C
something
rescue
Expand All @@ -141,18 +101,8 @@ module M
error
end
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
module M
something
rescue
error
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
module M
something
rescue
Expand All @@ -172,18 +122,8 @@ module M
error
end
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
begin
something
ensure
error
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
begin
something
ensure
Expand All @@ -203,18 +143,8 @@ def test
error
end
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
def test
something
ensure
error
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
def test
something
ensure
Expand All @@ -234,18 +164,8 @@ def Test.test
error
end
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
def Test.test
something
ensure
error
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
def Test.test
something
ensure
Expand All @@ -265,18 +185,8 @@ class C
error
end
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
class C
something
ensure
error
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
class C
something
ensure
Expand All @@ -296,18 +206,8 @@ module M
error
end
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
module M
something
ensure
error
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
module M
something
ensure
Expand Down Expand Up @@ -484,20 +384,8 @@ def foo
end
end
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
def foo
[1, 2, 3].each do |el|
el.to_s
rescue StandardError => _exception
next
end
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
def foo
[1, 2, 3].each do |el|
el.to_s
Expand Down Expand Up @@ -548,10 +436,8 @@ def foo
'baz'
end
RUBY
end

it 'correct alignment' do
expect_no_offenses(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
private def test
'foo'
rescue
Expand All @@ -560,16 +446,8 @@ def foo
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
private def test
'foo'
rescue
'baz'
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
it 'correct alignment' do
expect_no_offenses(<<-RUBY.strip_indent)
private def test
'foo'
rescue
Expand All @@ -589,10 +467,8 @@ def foo
'baz'
end
RUBY
end

it 'correct alignment' do
expect_no_offenses(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
private def Test.test
'foo'
rescue
Expand All @@ -601,16 +477,8 @@ def foo
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
private def Test.test
'foo'
rescue
'baz'
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
it 'correct alignment' do
expect_no_offenses(<<-RUBY.strip_indent)
private def Test.test
'foo'
rescue
Expand All @@ -630,10 +498,8 @@ def foo
'baz'
end
RUBY
end

it 'correct alignment' do
expect_no_offenses(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
private def test
'foo'
ensure
Expand All @@ -642,16 +508,8 @@ def foo
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
private def test
'foo'
ensure
'baz'
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
it 'correct alignment' do
expect_no_offenses(<<-RUBY.strip_indent)
private def test
'foo'
ensure
Expand All @@ -671,10 +529,8 @@ def foo
'baz'
end
RUBY
end

it 'correct alignment' do
expect_no_offenses(<<-RUBY.strip_indent)
expect_correction(<<-RUBY.strip_indent)
private def Test.test
'foo'
ensure
Expand All @@ -683,16 +539,8 @@ def foo
RUBY
end

it 'corrects the alignment' do
new_source = autocorrect_source(<<-RUBY.strip_indent)
private def Test.test
'foo'
ensure
'baz'
end
RUBY

expect(new_source).to eq(<<-RUBY.strip_indent)
it 'correct alignment' do
expect_no_offenses(<<-RUBY.strip_indent)
private def Test.test
'foo'
ensure
Expand All @@ -719,23 +567,8 @@ def test
end
end
RUBY
end

it 'does not correct alignment' do
source = <<-RUBY.strip_indent
def test
'foo'; rescue; 'baz'
end
def test
begin
'foo'; rescue; 'baz'
end
end
RUBY

new_source = autocorrect_source(source)
expect(new_source).to eq(source)
expect_no_corrections
end
end

Expand All @@ -754,23 +587,8 @@ def test
end
end
RUBY
end

it 'does not correct alignment' do
source = <<-RUBY.strip_indent
def test
'foo'; ensure; 'baz'
end
def test
begin
'foo'; ensure; 'baz'
end
end
RUBY

new_source = autocorrect_source(source)
expect(new_source).to eq(source)
expect_no_corrections
end
end
end
Expand Down
Loading

0 comments on commit 6834afe

Please sign in to comment.