@@ -209,43 +209,51 @@ def test_render_outside_path
209
209
end
210
210
end
211
211
212
- def test_render_runtime_error
213
- ex = assert_raises ( ActionView ::Template ::Error ) {
214
- @view . render ( template : "test/runtime_error" )
215
- }
216
- erb_btl = ex . backtrace_locations . first
212
+ if ActionView ::Template ::SOURCE_MAPPING_SUPPORTED
213
+ def test_render_template_with_syntax_error
214
+ e = assert_raises ( ActionView ::Template ::Error ) { @view . render ( template : "test/syntax_error" ) }
215
+ assert_match %r!syntax! , e . message
216
+ assert_equal "1: <%= foo(" , e . annotated_source_code [ 0 ] . strip
217
+ end
217
218
218
- # Get the spot information from ErrorHighlight
219
- translating_frame = ActionDispatch ::ExceptionWrapper ::SourceMapLocation . new ( erb_btl , ex . template )
220
- translated_spot = translating_frame . spot ( ex . cause )
219
+ def test_render_runtime_error
220
+ ex = assert_raises ( ActionView ::Template ::Error ) {
221
+ @view . render ( template : "test/runtime_error" )
222
+ }
223
+ erb_btl = ex . backtrace_locations . first
221
224
222
- assert_equal 6 , translated_spot [ :first_column ]
223
- end
225
+ # Get the spot information from ErrorHighlight
226
+ translating_frame = ActionDispatch ::ExceptionWrapper ::SourceMapLocation . new ( erb_btl , ex . template )
227
+ translated_spot = translating_frame . spot ( ex . cause )
224
228
225
- def test_render_location_conditional_append
226
- ex = assert_raises ( ActionView ::Template ::Error ) {
227
- @view . render ( template : "test/unparseable_runtime_error" )
228
- }
229
- erb_btl = ex . backtrace_locations . first
229
+ assert_equal 6 , translated_spot [ :first_column ]
230
+ end
230
231
231
- # Get the spot information from ErrorHighlight
232
- translating_frame = ActionDispatch ::ExceptionWrapper ::SourceMapLocation . new ( erb_btl , ex . template )
233
- translated_spot = translating_frame . spot ( ex . cause )
232
+ def test_render_location_conditional_append
233
+ ex = assert_raises ( ActionView ::Template ::Error ) {
234
+ @view . render ( template : "test/unparseable_runtime_error" )
235
+ }
236
+ erb_btl = ex . backtrace_locations . first
234
237
235
- assert_equal 8 , translated_spot [ :first_column ]
236
- end
238
+ # Get the spot information from ErrorHighlight
239
+ translating_frame = ActionDispatch ::ExceptionWrapper ::SourceMapLocation . new ( erb_btl , ex . template )
240
+ translated_spot = translating_frame . spot ( ex . cause )
237
241
238
- def test_render_location_conditional_append_2
239
- ex = assert_raises ( ActionView ::Template ::Error ) {
240
- @view . render ( template : "test/unparseable_runtime_error_2" )
241
- }
242
- erb_btl = ex . backtrace_locations . first
242
+ assert_equal 8 , translated_spot [ :first_column ]
243
+ end
243
244
244
- # Get the spot information from ErrorHighlight
245
- translating_frame = ActionDispatch ::ExceptionWrapper ::SourceMapLocation . new ( erb_btl , ex . template )
246
- translated_spot = translating_frame . spot ( ex . cause )
245
+ def test_render_location_conditional_append_2
246
+ ex = assert_raises ( ActionView ::Template ::Error ) {
247
+ @view . render ( template : "test/unparseable_runtime_error_2" )
248
+ }
249
+ erb_btl = ex . backtrace_locations . first
247
250
248
- assert_instance_of Integer , translated_spot [ :first_column ]
251
+ # Get the spot information from ErrorHighlight
252
+ translating_frame = ActionDispatch ::ExceptionWrapper ::SourceMapLocation . new ( erb_btl , ex . template )
253
+ translated_spot = translating_frame . spot ( ex . cause )
254
+
255
+ assert_instance_of Integer , translated_spot [ :first_column ]
256
+ end
249
257
end
250
258
251
259
def test_render_partial
@@ -346,12 +354,6 @@ def test_render_partial_with_hyphen_and_invalid_option_as
346
354
"and is followed by any combination of letters, numbers and underscores." , e . message
347
355
end
348
356
349
- def test_render_template_with_syntax_error
350
- e = assert_raises ( ActionView ::Template ::Error ) { @view . render ( template : "test/syntax_error" ) }
351
- assert_match %r!syntax! , e . message
352
- assert_equal "1: <%= foo(" , e . annotated_source_code [ 0 ] . strip
353
- end
354
-
355
357
def test_render_partial_with_errors
356
358
e = assert_raises ( ActionView ::Template ::Error ) { @view . render ( partial : "test/raise" ) }
357
359
assert_match %r!method.*doesnt_exist! , e . message
0 commit comments