File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -190,8 +190,10 @@ def expect_no_corrections
190
190
def expect_no_offenses ( source , file = nil )
191
191
offenses = inspect_source ( source , file )
192
192
193
- # Carets given in `expect_no_offenses` should not be treated as annotations so are escaped
194
- expected_annotations = AnnotatedSource . parse ( source . gsub ( '^' , '\^' ) )
193
+ # Since source given `expect_no_offenses` does not have annotations, we do not need to parse
194
+ # for them, and can just build an `AnnotatedSource` object from the source lines.
195
+ # This also prevents treating source lines that begin with a caret as an annotation.
196
+ expected_annotations = AnnotatedSource . new ( source . each_line . to_a , [ ] )
195
197
actual_annotations = expected_annotations . with_offense_annotations ( offenses )
196
198
expect ( actual_annotations . to_s ) . to eq ( source )
197
199
end
@@ -240,7 +242,7 @@ def self.parse(annotated_source)
240
242
if ANNOTATION_PATTERN . match? ( source_line )
241
243
annotations << [ source . size , source_line ]
242
244
else
243
- source << source_line . gsub ( '\^' , '^' )
245
+ source << source_line
244
246
end
245
247
end
246
248
annotations . each { |a | a [ 0 ] = 1 } if source . empty?
You can’t perform that action at this time.
0 commit comments