Skip to content

Commit aa0a9e3

Browse files
committed
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 ```
1 parent 32a43ed commit aa0a9e3

4 files changed

+44
-44
lines changed

spec/rubocop/cop/rspec/context_wording_spec.rb

+22-22
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
end
1414

1515
it 'finds context without `when` at the beginning' do
16-
expect_offense(<<-RUBY)
16+
expect_offense(<<-'RUBY')
1717
context 'the display name not present' do
18-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.
18+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /^when\b/, /^with\b/, or /^without\b/.
1919
end
2020
RUBY
2121
end
2222

2323
it 'finds shared_context without `when` at the beginning' do
24-
expect_offense(<<-RUBY)
24+
expect_offense(<<-'RUBY')
2525
shared_context 'the display name not present' do
26-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.
26+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /^when\b/, /^with\b/, or /^without\b/.
2727
end
2828
RUBY
2929
end
@@ -43,38 +43,38 @@
4343
end
4444

4545
it 'finds context without separate `when` at the beginning' do
46-
expect_offense(<<-RUBY)
46+
expect_offense(<<-'RUBY')
4747
context 'whenever you do' do
48-
^^^^^^^^^^^^^^^^^ Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.
48+
^^^^^^^^^^^^^^^^^ Context description should match /^when\b/, /^with\b/, or /^without\b/.
4949
end
5050
RUBY
5151
end
5252

5353
context 'with metadata hash' do
5454
it 'finds context without separate `when` at the beginning' do
55-
expect_offense(<<-RUBY)
55+
expect_offense(<<-'RUBY')
5656
context 'whenever you do', legend: true do
57-
^^^^^^^^^^^^^^^^^ Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.
57+
^^^^^^^^^^^^^^^^^ Context description should match /^when\b/, /^with\b/, or /^without\b/.
5858
end
5959
RUBY
6060
end
6161
end
6262

6363
context 'with symbol metadata' do
6464
it 'finds context without separate `when` at the beginning' do
65-
expect_offense(<<-RUBY)
65+
expect_offense(<<-'RUBY')
6666
context 'whenever you do', :legend do
67-
^^^^^^^^^^^^^^^^^ Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.
67+
^^^^^^^^^^^^^^^^^ Context description should match /^when\b/, /^with\b/, or /^without\b/.
6868
end
6969
RUBY
7070
end
7171
end
7272

7373
context 'with mixed metadata' do
7474
it 'finds context without separate `when` at the beginning' do
75-
expect_offense(<<-RUBY)
75+
expect_offense(<<-'RUBY')
7676
context 'whenever you do', :legend, myth: true do
77-
^^^^^^^^^^^^^^^^^ Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.
77+
^^^^^^^^^^^^^^^^^ Context description should match /^when\b/, /^with\b/, or /^without\b/.
7878
end
7979
RUBY
8080
end
@@ -84,9 +84,9 @@
8484
let(:cop_config) { { 'Prefixes' => %w[if], 'AllowedPatterns' => [] } }
8585

8686
it 'finds context without allowed prefixes at the beginning' do
87-
expect_offense(<<-RUBY)
87+
expect_offense(<<-'RUBY')
8888
context 'when display name is present' do
89-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /^if\\b/.
89+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /^if\b/.
9090
end
9191
RUBY
9292
end
@@ -115,16 +115,16 @@
115115
let(:cop_config) { { 'Prefixes' => ['a$b\d'], 'AllowedPatterns' => [] } }
116116

117117
it 'matches the full prefix' do
118-
expect_offense(<<-RUBY)
118+
expect_offense(<<-'RUBY')
119119
context 'a' do
120-
^^^ Context description should match /^a\\$b\\\\d\\b/.
120+
^^^ Context description should match /^a\$b\\d\b/.
121121
end
122122
RUBY
123123
end
124124

125125
it 'matches special characters' do
126-
expect_no_offenses(<<-RUBY)
127-
context 'a$b\\d something' do
126+
expect_no_offenses(<<-'RUBY')
127+
context 'a$b\d something' do
128128
end
129129
RUBY
130130
end
@@ -166,18 +166,18 @@
166166

167167
it 'finds context without `when` at the beginning and not included ' \
168168
'`/patterns/`' do
169-
expect_offense(<<-RUBY)
169+
expect_offense(<<-'RUBY')
170170
context 'this is an incorrect context' do
171-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /patterns/, or /^when\\b/.
171+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /patterns/, or /^when\b/.
172172
end
173173
RUBY
174174
end
175175

176176
it 'finds shared_context without `when` at the beginning and ' \
177177
'not included `/patterns/`' do
178-
expect_offense(<<-RUBY)
178+
expect_offense(<<-'RUBY')
179179
shared_context 'this is an incorrect context' do
180-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /patterns/, or /^when\\b/.
180+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Context description should match /patterns/, or /^when\b/.
181181
end
182182
RUBY
183183
end

spec/rubocop/cop/rspec/example_wording_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@
151151
end
152152

153153
it 'flags \-separated multiline strings' do
154-
expect_offense(<<-RUBY)
155-
it 'should do something ' \\
154+
expect_offense(<<-'RUBY')
155+
it 'should do something ' \
156156
^^^^^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
157157
'and correctly fix' do
158158
end

spec/rubocop/cop/rspec/excessive_docstring_spacing_spec.rb

+16-16
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,17 @@
120120

121121
it 'skips \-separated multiline strings whose trailing whitespace ' \
122122
'makes sense' do
123-
expect_no_offenses(<<-RUBY)
124-
describe '#mymethod ' \\
123+
expect_no_offenses(<<-'RUBY')
124+
describe '#mymethod ' \
125125
'(is cool)' do
126126
end
127127
RUBY
128128
end
129129

130130
it 'flags \-separated multiline strings whose trailing whitespace ' \
131131
'does not make sense' do
132-
expect_offense(<<-RUBY)
133-
describe '#mymethod ' \\
132+
expect_offense(<<-'RUBY')
133+
describe '#mymethod ' \
134134
^^^^^^^^^^^^^^^ Excessive whitespace.
135135
'(is cool)' do
136136
end
@@ -287,17 +287,17 @@
287287

288288
it 'skips \-separated multiline strings whose trailing whitespace ' \
289289
'makes sense' do
290-
expect_no_offenses(<<-RUBY)
291-
context 'when doing something ' \\
290+
expect_no_offenses(<<-'RUBY')
291+
context 'when doing something ' \
292292
'like this' do
293293
end
294294
RUBY
295295
end
296296

297297
it 'flags \-separated multiline strings whose trailing whitespace ' \
298298
'does not make sense' do
299-
expect_offense(<<-RUBY)
300-
context 'when doing something ' \\
299+
expect_offense(<<-'RUBY')
300+
context 'when doing something ' \
301301
^^^^^^^^^^^^^^^^^^^^^^^^^^ Excessive whitespace.
302302
'like this' do
303303
end
@@ -479,17 +479,17 @@
479479

480480
it 'skips \-separated multiline strings whose trailing whitespace ' \
481481
'makes sense' do
482-
expect_no_offenses(<<-RUBY)
483-
it 'should do something ' \\
482+
expect_no_offenses(<<-'RUBY')
483+
it 'should do something ' \
484484
'and correctly fix' do
485485
end
486486
RUBY
487487
end
488488

489489
it 'flags \-separated multiline strings whose trailing whitespace ' \
490490
'does not make sense' do
491-
expect_offense(<<-RUBY)
492-
it 'does something ' \\
491+
expect_offense(<<-'RUBY')
492+
it 'does something ' \
493493
^^^^^^^^^^^^^^^^^^^^ Excessive whitespace.
494494
'and correctly fix' do
495495
end
@@ -556,8 +556,8 @@
556556
end
557557

558558
it 'supports `skip` (with a block)' do
559-
expect_offense(<<-RUBY)
560-
skip ' this please ' \\
559+
expect_offense(<<-'RUBY')
560+
skip ' this please ' \
561561
^^^^^^^^^^^^^^^^^^^^^ Excessive whitespace.
562562
' and thank you !' do
563563
end
@@ -570,8 +570,8 @@
570570
end
571571

572572
it 'supports `skip` (without a block)' do
573-
expect_offense(<<-RUBY)
574-
skip ' this please ' \\
573+
expect_offense(<<-'RUBY')
574+
skip ' this please ' \
575575
^^^^^^^^^^^^^^^^^^^^^ Excessive whitespace.
576576
' and thank you !'
577577
RUBY

spec/rubocop/cop/rspec/return_from_stub_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,14 @@ def stub_foo
272272
end
273273

274274
it 'finds concatenated strings with no variables' do
275-
expect_offense(<<-RUBY)
276-
allow(Foo).to receive(:bar).and_return('You called ' \\
275+
expect_offense(<<-'RUBY')
276+
allow(Foo).to receive(:bar).and_return('You called ' \
277277
^^^^^^^^^^ Use block for static values.
278278
'me')
279279
RUBY
280280

281-
expect_correction(<<-RUBY)
282-
allow(Foo).to receive(:bar) { 'You called ' \\
281+
expect_correction(<<-'RUBY')
282+
allow(Foo).to receive(:bar) { 'You called ' \
283283
'me' }
284284
RUBY
285285
end

0 commit comments

Comments
 (0)