From aa0a9e3cad69ec8fe72c21c798a788b2c3982aaf Mon Sep 17 00:00:00 2001 From: ydah <13041216+ydah@users.noreply.github.com> Date: Tue, 10 Jan 2023 20:22:05 +0900 Subject: [PATCH] Change the start label of a heredocument to be enclosed in single quotes This PR is change as follows ```ruby expect_offense(<<-RUBY) # ... end expect_offense(<<-'RUBY') # ... end ``` --- .../rubocop/cop/rspec/context_wording_spec.rb | 44 +++++++++---------- .../rubocop/cop/rspec/example_wording_spec.rb | 4 +- .../rspec/excessive_docstring_spacing_spec.rb | 32 +++++++------- .../cop/rspec/return_from_stub_spec.rb | 8 ++-- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/spec/rubocop/cop/rspec/context_wording_spec.rb b/spec/rubocop/cop/rspec/context_wording_spec.rb index 875bf557a..ac8e62570 100644 --- a/spec/rubocop/cop/rspec/context_wording_spec.rb +++ b/spec/rubocop/cop/rspec/context_wording_spec.rb @@ -13,17 +13,17 @@ end it 'finds context without `when` at the beginning' do - expect_offense(<<-RUBY) + expect_offense(<<-'RUBY') context 'the display name not present' do - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /^when\\b/, /^with\\b/, or /^without\\b/. + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /^when\b/, /^with\b/, or /^without\b/. end RUBY end it 'finds shared_context without `when` at the beginning' do - expect_offense(<<-RUBY) + expect_offense(<<-'RUBY') shared_context 'the display name not present' do - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /^when\\b/, /^with\\b/, or /^without\\b/. + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /^when\b/, /^with\b/, or /^without\b/. end RUBY end @@ -43,18 +43,18 @@ end it 'finds context without separate `when` at the beginning' do - expect_offense(<<-RUBY) + expect_offense(<<-'RUBY') context 'whenever you do' do - ^^^^^^^^^^^^^^^^^ Context description should match /^when\\b/, /^with\\b/, or /^without\\b/. + ^^^^^^^^^^^^^^^^^ Context description should match /^when\b/, /^with\b/, or /^without\b/. end RUBY end context 'with metadata hash' do it 'finds context without separate `when` at the beginning' do - expect_offense(<<-RUBY) + expect_offense(<<-'RUBY') context 'whenever you do', legend: true do - ^^^^^^^^^^^^^^^^^ Context description should match /^when\\b/, /^with\\b/, or /^without\\b/. + ^^^^^^^^^^^^^^^^^ Context description should match /^when\b/, /^with\b/, or /^without\b/. end RUBY end @@ -62,9 +62,9 @@ context 'with symbol metadata' do it 'finds context without separate `when` at the beginning' do - expect_offense(<<-RUBY) + expect_offense(<<-'RUBY') context 'whenever you do', :legend do - ^^^^^^^^^^^^^^^^^ Context description should match /^when\\b/, /^with\\b/, or /^without\\b/. + ^^^^^^^^^^^^^^^^^ Context description should match /^when\b/, /^with\b/, or /^without\b/. end RUBY end @@ -72,9 +72,9 @@ context 'with mixed metadata' do it 'finds context without separate `when` at the beginning' do - expect_offense(<<-RUBY) + expect_offense(<<-'RUBY') context 'whenever you do', :legend, myth: true do - ^^^^^^^^^^^^^^^^^ Context description should match /^when\\b/, /^with\\b/, or /^without\\b/. + ^^^^^^^^^^^^^^^^^ Context description should match /^when\b/, /^with\b/, or /^without\b/. end RUBY end @@ -84,9 +84,9 @@ let(:cop_config) { { 'Prefixes' => %w[if], 'AllowedPatterns' => [] } } it 'finds context without allowed prefixes at the beginning' do - expect_offense(<<-RUBY) + expect_offense(<<-'RUBY') context 'when display name is present' do - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /^if\\b/. + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /^if\b/. end RUBY end @@ -115,16 +115,16 @@ let(:cop_config) { { 'Prefixes' => ['a$b\d'], 'AllowedPatterns' => [] } } it 'matches the full prefix' do - expect_offense(<<-RUBY) + expect_offense(<<-'RUBY') context 'a' do - ^^^ Context description should match /^a\\$b\\\\d\\b/. + ^^^ Context description should match /^a\$b\\d\b/. end RUBY end it 'matches special characters' do - expect_no_offenses(<<-RUBY) - context 'a$b\\d something' do + expect_no_offenses(<<-'RUBY') + context 'a$b\d something' do end RUBY end @@ -166,18 +166,18 @@ it 'finds context without `when` at the beginning and not included ' \ '`/patterns/`' do - expect_offense(<<-RUBY) + expect_offense(<<-'RUBY') context 'this is an incorrect context' do - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /patterns/, or /^when\\b/. + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /patterns/, or /^when\b/. end RUBY end it 'finds shared_context without `when` at the beginning and ' \ 'not included `/patterns/`' do - expect_offense(<<-RUBY) + expect_offense(<<-'RUBY') shared_context 'this is an incorrect context' do - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /patterns/, or /^when\\b/. + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /patterns/, or /^when\b/. end RUBY end diff --git a/spec/rubocop/cop/rspec/example_wording_spec.rb b/spec/rubocop/cop/rspec/example_wording_spec.rb index 0a76ad836..7a45d8c61 100644 --- a/spec/rubocop/cop/rspec/example_wording_spec.rb +++ b/spec/rubocop/cop/rspec/example_wording_spec.rb @@ -151,8 +151,8 @@ end it 'flags \-separated multiline strings' do - expect_offense(<<-RUBY) - it 'should do something ' \\ + expect_offense(<<-'RUBY') + it 'should do something ' \ ^^^^^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests. 'and correctly fix' do end diff --git a/spec/rubocop/cop/rspec/excessive_docstring_spacing_spec.rb b/spec/rubocop/cop/rspec/excessive_docstring_spacing_spec.rb index 5e4e0039b..432040573 100644 --- a/spec/rubocop/cop/rspec/excessive_docstring_spacing_spec.rb +++ b/spec/rubocop/cop/rspec/excessive_docstring_spacing_spec.rb @@ -120,8 +120,8 @@ it 'skips \-separated multiline strings whose trailing whitespace ' \ 'makes sense' do - expect_no_offenses(<<-RUBY) - describe '#mymethod ' \\ + expect_no_offenses(<<-'RUBY') + describe '#mymethod ' \ '(is cool)' do end RUBY @@ -129,8 +129,8 @@ it 'flags \-separated multiline strings whose trailing whitespace ' \ 'does not make sense' do - expect_offense(<<-RUBY) - describe '#mymethod ' \\ + expect_offense(<<-'RUBY') + describe '#mymethod ' \ ^^^^^^^^^^^^^^^ Excessive whitespace. '(is cool)' do end @@ -287,8 +287,8 @@ it 'skips \-separated multiline strings whose trailing whitespace ' \ 'makes sense' do - expect_no_offenses(<<-RUBY) - context 'when doing something ' \\ + expect_no_offenses(<<-'RUBY') + context 'when doing something ' \ 'like this' do end RUBY @@ -296,8 +296,8 @@ it 'flags \-separated multiline strings whose trailing whitespace ' \ 'does not make sense' do - expect_offense(<<-RUBY) - context 'when doing something ' \\ + expect_offense(<<-'RUBY') + context 'when doing something ' \ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Excessive whitespace. 'like this' do end @@ -479,8 +479,8 @@ it 'skips \-separated multiline strings whose trailing whitespace ' \ 'makes sense' do - expect_no_offenses(<<-RUBY) - it 'should do something ' \\ + expect_no_offenses(<<-'RUBY') + it 'should do something ' \ 'and correctly fix' do end RUBY @@ -488,8 +488,8 @@ it 'flags \-separated multiline strings whose trailing whitespace ' \ 'does not make sense' do - expect_offense(<<-RUBY) - it 'does something ' \\ + expect_offense(<<-'RUBY') + it 'does something ' \ ^^^^^^^^^^^^^^^^^^^^ Excessive whitespace. 'and correctly fix' do end @@ -556,8 +556,8 @@ end it 'supports `skip` (with a block)' do - expect_offense(<<-RUBY) - skip ' this please ' \\ + expect_offense(<<-'RUBY') + skip ' this please ' \ ^^^^^^^^^^^^^^^^^^^^^ Excessive whitespace. ' and thank you !' do end @@ -570,8 +570,8 @@ end it 'supports `skip` (without a block)' do - expect_offense(<<-RUBY) - skip ' this please ' \\ + expect_offense(<<-'RUBY') + skip ' this please ' \ ^^^^^^^^^^^^^^^^^^^^^ Excessive whitespace. ' and thank you !' RUBY diff --git a/spec/rubocop/cop/rspec/return_from_stub_spec.rb b/spec/rubocop/cop/rspec/return_from_stub_spec.rb index 5af3ca1bd..4a04840f4 100644 --- a/spec/rubocop/cop/rspec/return_from_stub_spec.rb +++ b/spec/rubocop/cop/rspec/return_from_stub_spec.rb @@ -272,14 +272,14 @@ def stub_foo end it 'finds concatenated strings with no variables' do - expect_offense(<<-RUBY) - allow(Foo).to receive(:bar).and_return('You called ' \\ + expect_offense(<<-'RUBY') + allow(Foo).to receive(:bar).and_return('You called ' \ ^^^^^^^^^^ Use block for static values. 'me') RUBY - expect_correction(<<-RUBY) - allow(Foo).to receive(:bar) { 'You called ' \\ + expect_correction(<<-'RUBY') + allow(Foo).to receive(:bar) { 'You called ' \ 'me' } RUBY end