diff --git a/lib/rubocop/rspec/expect_offense.rb b/lib/rubocop/rspec/expect_offense.rb index 7b91f680c46..db5f0f3c198 100644 --- a/lib/rubocop/rspec/expect_offense.rb +++ b/lib/rubocop/rspec/expect_offense.rb @@ -115,7 +115,7 @@ def expect_offense(source, file = nil, **replacements) expect(actual_annotations.to_s).to eq(expected_annotations.to_s) end - def expect_correction(correction, loop: false) + def expect_correction(correction, loop: true) raise '`expect_correction` must follow `expect_offense`' unless @processed_source iteration = 0 diff --git a/spec/rubocop/cop/bundler/ordered_gems_spec.rb b/spec/rubocop/cop/bundler/ordered_gems_spec.rb index 1f5c09e8bf8..6e6d74bf6f0 100644 --- a/spec/rubocop/cop/bundler/ordered_gems_spec.rb +++ b/spec/rubocop/cop/bundler/ordered_gems_spec.rb @@ -105,7 +105,7 @@ gem "i" RUBY - expect_correction(<<~RUBY, loop: true) + expect_correction(<<~RUBY) gem "a" gem "b" gem "c" @@ -167,7 +167,7 @@ gem 'rspec' # For test RUBY - expect_correction(<<~RUBY, loop: true) + expect_correction(<<~RUBY) gem 'pry' gem 'rspec' # For test gem 'rubocop' # For code quality diff --git a/spec/rubocop/cop/layout/array_alignment_spec.rb b/spec/rubocop/cop/layout/array_alignment_spec.rb index 087349905b9..a9b108d3d8d 100644 --- a/spec/rubocop/cop/layout/array_alignment_spec.rb +++ b/spec/rubocop/cop/layout/array_alignment_spec.rb @@ -92,7 +92,7 @@ [:l4]]]] RUBY - expect_correction(<<~RUBY) + expect_correction(<<~RUBY, loop: false) [:l1, [:l2, [:l3, @@ -251,7 +251,7 @@ [:l4]]]] RUBY - expect_correction(<<~RUBY) + expect_correction(<<~RUBY, loop: false) [:l1, [:l2, [:l3, diff --git a/spec/rubocop/cop/layout/class_structure_spec.rb b/spec/rubocop/cop/layout/class_structure_spec.rb index ce6d97fd4f3..68251086958 100644 --- a/spec/rubocop/cop/layout/class_structure_spec.rb +++ b/spec/rubocop/cop/layout/class_structure_spec.rb @@ -107,7 +107,7 @@ class Person end RUBY - expect_correction(<<~RUBY, loop: true) + expect_correction(<<~RUBY) class Person include AnotherModule extend SomeModule diff --git a/spec/rubocop/cop/layout/extra_spacing_spec.rb b/spec/rubocop/cop/layout/extra_spacing_spec.rb index 93494cc9b88..ced87d103df 100644 --- a/spec/rubocop/cop/layout/extra_spacing_spec.rb +++ b/spec/rubocop/cop/layout/extra_spacing_spec.rb @@ -529,7 +529,7 @@ def batch end RUBY - expect_correction(<<~RUBY) + expect_correction(<<~RUBY, loop: false) def batch @areas = params[:param].map { var_1 = 123_456 diff --git a/spec/rubocop/cop/layout/heredoc_argument_closing_parenthesis_spec.rb b/spec/rubocop/cop/layout/heredoc_argument_closing_parenthesis_spec.rb index 67590ae7fcf..632d1187b29 100644 --- a/spec/rubocop/cop/layout/heredoc_argument_closing_parenthesis_spec.rb +++ b/spec/rubocop/cop/layout/heredoc_argument_closing_parenthesis_spec.rb @@ -395,7 +395,7 @@ ) RUBY - expect_correction(<<~RUBY) + expect_correction(<<~RUBY, loop: false) bar( foo(123, <<-SQL), foo @@ -503,7 +503,7 @@ ^ Put the closing parenthesis for a method call with a HEREDOC parameter on the same line as the HEREDOC opening. RUBY - expect_correction(<<~RUBY) + expect_correction(<<~RUBY, loop: false) query.order(Arel.sql(<<-SQL) foo SQL diff --git a/spec/rubocop/cop/layout/heredoc_indentation_spec.rb b/spec/rubocop/cop/layout/heredoc_indentation_spec.rb index 7b67050b4b9..491ca3fecc2 100644 --- a/spec/rubocop/cop/layout/heredoc_indentation_spec.rb +++ b/spec/rubocop/cop/layout/heredoc_indentation_spec.rb @@ -128,7 +128,7 @@ def foo RUBY2 RUBY - expect_correction(<<~CORRECTION, loop: true) + expect_correction(<<~CORRECTION) <<~#{quote}RUBY2#{quote} foo RUBY2 @@ -160,7 +160,7 @@ def foo RUBY2 RUBY - expect_correction(<<-CORRECTION, loop: true) + expect_correction(<<-CORRECTION) puts <<~#{quote}RUBY2#{quote} def foo bar diff --git a/spec/rubocop/cop/layout/space_around_block_parameters_spec.rb b/spec/rubocop/cop/layout/space_around_block_parameters_spec.rb index 8ba4f292ea0..3a9e3be9e4f 100644 --- a/spec/rubocop/cop/layout/space_around_block_parameters_spec.rb +++ b/spec/rubocop/cop/layout/space_around_block_parameters_spec.rb @@ -359,7 +359,7 @@ ^ Space after last block parameter missing. RUBY - expect_correction(<<~RUBY) + expect_correction(<<~RUBY, loop: false) {}.each { | x ,| puts x } RUBY end diff --git a/spec/rubocop/cop/layout/space_inside_array_literal_brackets_spec.rb b/spec/rubocop/cop/layout/space_inside_array_literal_brackets_spec.rb index 84f4fac046d..6365f455e9b 100644 --- a/spec/rubocop/cop/layout/space_inside_array_literal_brackets_spec.rb +++ b/spec/rubocop/cop/layout/space_inside_array_literal_brackets_spec.rb @@ -527,7 +527,7 @@ def Vector.[](*array) ^ Do not use space inside array brackets. RUBY - expect_correction(<<~RUBY) + expect_correction(<<~RUBY, loop: false) multiline = [ [ 1, 2, 3, 4 ], [ 3, 4, 5, 6 ]] RUBY diff --git a/spec/rubocop/cop/lint/useless_access_modifier_spec.rb b/spec/rubocop/cop/lint/useless_access_modifier_spec.rb index 72834ff6d71..ddef8dcd8eb 100644 --- a/spec/rubocop/cop/lint/useless_access_modifier_spec.rb +++ b/spec/rubocop/cop/lint/useless_access_modifier_spec.rb @@ -634,7 +634,7 @@ def method2 end RUBY - expect_correction(<<~RUBY) + expect_correction(<<~RUBY, loop: false) #{keyword} A private def method1 diff --git a/spec/rubocop/cop/style/conditional_assignment_assign_to_condition_spec.rb b/spec/rubocop/cop/style/conditional_assignment_assign_to_condition_spec.rb index 9321616d1d6..d0f3cb88508 100644 --- a/spec/rubocop/cop/style/conditional_assignment_assign_to_condition_spec.rb +++ b/spec/rubocop/cop/style/conditional_assignment_assign_to_condition_spec.rb @@ -64,7 +64,7 @@ it 'autocorrects the inner offense first' do expect_offense(annotated_source) - expect_correction(<<~RUBY) + expect_correction(<<~RUBY, loop: false) if var.any?(:prob_a_check) @errors << 'Problem A' elsif var.any?(:prob_a_check) @@ -2079,7 +2079,7 @@ end RUBY - expect_correction(<<~RUBY) + expect_correction(<<~RUBY, loop: false) unless foo baz = if foobar 1 @@ -2212,7 +2212,7 @@ it 'does not consider branches of nested ifs' do expect_offense(annotated_source) - expect_correction(<<~RUBY) + expect_correction(<<~RUBY, loop: false) if outer bar = 1 else diff --git a/spec/rubocop/cop/style/rescue_modifier_spec.rb b/spec/rubocop/cop/style/rescue_modifier_spec.rb index 3d3c68350d6..dedc5cd7fa3 100644 --- a/spec/rubocop/cop/style/rescue_modifier_spec.rb +++ b/spec/rubocop/cop/style/rescue_modifier_spec.rb @@ -210,7 +210,7 @@ def foo ^^^^^^^^^^^^^^^^^^^^^^ Avoid using `rescue` in its modifier form. RUBY - expect_correction(<<~RUBY, loop: true) + expect_correction(<<~RUBY) begin begin blah