Skip to content

Commit ba5fb99

Browse files
committed
Rename with_error_mode(...) to with_error_modes(...)
1 parent 8c8a843 commit ba5fb99

12 files changed

+77
-77
lines changed

test/integration/context_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ def notice(output)
632632
end
633633

634634
def test_has_key_will_not_add_an_error_for_missing_keys
635-
with_error_mode(:strict) do
635+
with_error_modes(:strict) do
636636
context = Context.new
637637
context.key?('unknown')
638638
assert_empty(context.errors)

test/integration/error_handling_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_missing_endtag_parse_time_error
6767
end
6868

6969
def test_unrecognized_operator
70-
with_error_mode(:strict) do
70+
with_error_modes(:strict) do
7171
assert_raises(SyntaxError) do
7272
Liquid::Template.parse(' {% if 1 =! 2 %}ok{% endif %} ')
7373
end

test/integration/expression_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_float
2727
assert_template_result("-17.42", "{{ -17.42 }}")
2828
assert_template_result("2.5", "{{ 2.5 }}")
2929

30-
with_error_mode(:lax) do
30+
with_error_modes(:lax) do
3131
assert_expression_result(0.0, "0.....5")
3232
assert_expression_result(0.0, "-0..1")
3333
end

test/integration/parsing_quirks_test.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ def test_raise_on_label_and_no_close_bracets_percent
3131
def test_error_on_empty_filter
3232
assert(Template.parse("{{test}}"))
3333

34-
with_error_mode(:lax) do
34+
with_error_modes(:lax) do
3535
assert(Template.parse("{{|test}}"))
3636
end
3737

38-
with_error_mode(:strict) do
38+
with_error_modes(:strict) do
3939
assert_raises(SyntaxError) { Template.parse("{{|test}}") }
4040
assert_raises(SyntaxError) { Template.parse("{{test |a|b|}}") }
4141
end
4242
end
4343

4444
def test_meaningless_parens_error
45-
with_error_mode(:strict) do
45+
with_error_modes(:strict) do
4646
assert_raises(SyntaxError) do
4747
markup = "a == 'foo' or (b == 'bar' and c == 'baz') or false"
4848
Template.parse("{% if #{markup} %} YES {% endif %}")
@@ -51,7 +51,7 @@ def test_meaningless_parens_error
5151
end
5252

5353
def test_unexpected_characters_syntax_error
54-
with_error_mode(:strict) do
54+
with_error_modes(:strict) do
5555
assert_raises(SyntaxError) do
5656
markup = "true && false"
5757
Template.parse("{% if #{markup} %} YES {% endif %}")
@@ -70,15 +70,15 @@ def test_no_error_on_lax_empty_filter
7070
end
7171

7272
def test_meaningless_parens_lax
73-
with_error_mode(:lax) do
73+
with_error_modes(:lax) do
7474
assigns = { 'b' => 'bar', 'c' => 'baz' }
7575
markup = "a == 'foo' or (b == 'bar' and c == 'baz') or false"
7676
assert_template_result(' YES ', "{% if #{markup} %} YES {% endif %}", assigns)
7777
end
7878
end
7979

8080
def test_unexpected_characters_silently_eat_logic_lax
81-
with_error_mode(:lax) do
81+
with_error_modes(:lax) do
8282
markup = "true && false"
8383
assert_template_result(' YES ', "{% if #{markup} %} YES {% endif %}")
8484
markup = "false || true"
@@ -93,7 +93,7 @@ def test_raise_on_invalid_tag_delimiter
9393
end
9494

9595
def test_unanchored_filter_arguments
96-
with_error_mode(:lax) do
96+
with_error_modes(:lax) do
9797
assert_template_result('hi', "{{ 'hi there' | split$$$:' ' | first }}")
9898

9999
assert_template_result('x', "{{ 'X' | downcase) }}")
@@ -106,14 +106,14 @@ def test_unanchored_filter_arguments
106106
end
107107

108108
def test_invalid_variables_work
109-
with_error_mode(:lax) do
109+
with_error_modes(:lax) do
110110
assert_template_result('bar', "{% assign 123foo = 'bar' %}{{ 123foo }}")
111111
assert_template_result('123', "{% assign 123 = 'bar' %}{{ 123 }}")
112112
end
113113
end
114114

115115
def test_extra_dots_in_ranges
116-
with_error_mode(:lax) do
116+
with_error_modes(:lax) do
117117
assert_template_result('12345', "{% for i in (1...5) %}{{ i }}{% endfor %}")
118118
end
119119
end
@@ -133,7 +133,7 @@ def test_contains_in_id
133133
end
134134

135135
def test_incomplete_expression
136-
with_error_mode(:lax) do
136+
with_error_modes(:lax) do
137137
assert_template_result("false", "{{ false - }}")
138138
assert_template_result("false", "{{ false > }}")
139139
assert_template_result("false", "{{ false < }}")

test/integration/tags/cycle_tag_test.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ def test_cycle_tag_with_error_mode
9696
template1 = "{% assign 5 = 'b' %}{% cycle .5, .4 %}"
9797
template2 = "{% cycle .5: 'a', 'b' %}"
9898

99-
with_error_mode(:lax, :strict) do
99+
with_error_modes(:lax, :strict) do
100100
assert_template_result("b", template1)
101101
assert_template_result("a", template2)
102102
end
103103

104-
with_error_mode(:rigid) do
104+
with_error_modes(:rigid) do
105105
error1 = assert_raises(Liquid::SyntaxError) { Template.parse(template1) }
106106
error2 = assert_raises(Liquid::SyntaxError) { Template.parse(template2) }
107107

@@ -121,15 +121,15 @@ def test_cycle_with_trailing_elements
121121
template4 = "#{assignments}{% cycle n e: 'a', 'b', 'c' %}"
122122
template5 = "#{assignments}{% cycle n e 'a', 'b', 'c' %}"
123123

124-
with_error_mode(:lax, :strict) do
124+
with_error_modes(:lax, :strict) do
125125
assert_template_result("a", template1)
126126
assert_template_result("a", template2)
127127
assert_template_result("a", template3)
128128
assert_template_result("N", template4)
129129
assert_template_result("N", template5)
130130
end
131131

132-
with_error_mode(:rigid) do
132+
with_error_modes(:rigid) do
133133
error1 = assert_raises(Liquid::SyntaxError) { Template.parse(template1) }
134134
error2 = assert_raises(Liquid::SyntaxError) { Template.parse(template2) }
135135
error3 = assert_raises(Liquid::SyntaxError) { Template.parse(template3) }
@@ -153,11 +153,11 @@ def test_cycle_name_with_invalid_expression
153153
{% endfor %}
154154
LIQUID
155155

156-
with_error_mode(:lax, :strict) do
156+
with_error_modes(:lax, :strict) do
157157
refute_nil(Template.parse(template))
158158
end
159159

160-
with_error_mode(:rigid) do
160+
with_error_modes(:rigid) do
161161
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
162162
assert_match(/Unexpected character =/, error.message)
163163
end
@@ -170,11 +170,11 @@ def test_cycle_variable_with_invalid_expression
170170
{% endfor %}
171171
LIQUID
172172

173-
with_error_mode(:lax, :strict) do
173+
with_error_modes(:lax, :strict) do
174174
refute_nil(Template.parse(template))
175175
end
176176

177-
with_error_mode(:rigid) do
177+
with_error_modes(:rigid) do
178178
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
179179
assert_match(/Unexpected character =/, error.message)
180180
end

test/integration/tags/include_tag_test.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,15 @@ def test_dynamically_choosen_template
205205
end
206206

207207
def test_rigid_parsing_errors
208-
with_error_mode(:lax, :strict) do
208+
with_error_modes(:lax, :strict) do
209209
assert_template_result(
210210
'hello value1 value2',
211211
'{% include "snippet" !!! arg1: "value1" ~~~ arg2: "value2" %}',
212212
partials: { 'snippet' => 'hello {{ arg1 }} {{ arg2 }}' },
213213
)
214214
end
215215

216-
with_error_mode(:rigid) do
216+
with_error_modes(:rigid) do
217217
assert_syntax_error(
218218
'{% include "snippet" !!! arg1: "value1" ~~~ arg2: "value2" %}',
219219
)
@@ -303,13 +303,13 @@ def test_passing_options_to_included_templates
303303
assert_raises(Liquid::SyntaxError) do
304304
Template.parse("{% include template %}", error_mode: :strict, environment: env).render!("template" => '{{ "X" || downcase }}')
305305
end
306-
with_error_mode(:lax) do
306+
with_error_modes(:lax) do
307307
assert_equal('x', Template.parse("{% include template %}", error_mode: :strict, include_options_blacklist: true, environment: env).render!("template" => '{{ "X" || downcase }}'))
308308
end
309309
assert_raises(Liquid::SyntaxError) do
310310
Template.parse("{% include template %}", error_mode: :strict, include_options_blacklist: [:locale], environment: env).render!("template" => '{{ "X" || downcase }}')
311311
end
312-
with_error_mode(:lax) do
312+
with_error_modes(:lax) do
313313
assert_equal('x', Template.parse("{% include template %}", error_mode: :strict, include_options_blacklist: [:error_mode], environment: env).render!("template" => '{{ "X" || downcase }}'))
314314
end
315315
end
@@ -404,11 +404,11 @@ def test_render_tag_renders_error_with_template_name_from_template_factory
404404
def test_include_template_with_invalid_expression
405405
template = "{% include foo=>bar %}"
406406

407-
with_error_mode(:lax, :strict) do
407+
with_error_modes(:lax, :strict) do
408408
refute_nil(Template.parse(template))
409409
end
410410

411-
with_error_mode(:rigid) do
411+
with_error_modes(:rigid) do
412412
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
413413
assert_match(/Unexpected character =/, error.message)
414414
end
@@ -417,11 +417,11 @@ def test_include_template_with_invalid_expression
417417
def test_include_with_invalid_expression
418418
template = '{% include "snippet" with foo=>bar %}'
419419

420-
with_error_mode(:lax, :strict) do
420+
with_error_modes(:lax, :strict) do
421421
refute_nil(Template.parse(template))
422422
end
423423

424-
with_error_mode(:rigid) do
424+
with_error_modes(:rigid) do
425425
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
426426
assert_match(/Unexpected character =/, error.message)
427427
end
@@ -430,11 +430,11 @@ def test_include_with_invalid_expression
430430
def test_include_attribute_with_invalid_expression
431431
template = '{% include "snippet", key: foo=>bar %}'
432432

433-
with_error_mode(:lax, :strict) do
433+
with_error_modes(:lax, :strict) do
434434
refute_nil(Template.parse(template))
435435
end
436436

437-
with_error_mode(:rigid) do
437+
with_error_modes(:rigid) do
438438
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
439439
assert_match(/Unexpected character =/, error.message)
440440
end

test/integration/tags/render_tag_test.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ def test_dynamically_choosen_templates_are_not_allowed
106106
end
107107

108108
def test_rigid_parsing_errors
109-
with_error_mode(:lax, :strict) do
109+
with_error_modes(:lax, :strict) do
110110
assert_template_result(
111111
'hello value1 value2',
112112
'{% render "snippet" !!! arg1: "value1" ~~~ arg2: "value2" %}',
113113
partials: { 'snippet' => 'hello {{ arg1 }} {{ arg2 }}' },
114114
)
115115
end
116116

117-
with_error_mode(:rigid) do
117+
with_error_modes(:rigid) do
118118
assert_syntax_error(
119119
'{% render "snippet" !!! arg1: "value1" ~~~ arg2: "value2" %}',
120120
)
@@ -318,11 +318,11 @@ def test_render_tag_renders_error_with_template_name_from_template_factory
318318
def test_render_with_invalid_expression
319319
template = '{% render "snippet" with foo=>bar %}'
320320

321-
with_error_mode(:lax, :strict) do
321+
with_error_modes(:lax, :strict) do
322322
refute_nil(Template.parse(template))
323323
end
324324

325-
with_error_mode(:rigid) do
325+
with_error_modes(:rigid) do
326326
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
327327
assert_match(/Unexpected character =/, error.message)
328328
end
@@ -331,11 +331,11 @@ def test_render_with_invalid_expression
331331
def test_render_attribute_with_invalid_expression
332332
template = '{% render "snippet", key: foo=>bar %}'
333333

334-
with_error_mode(:lax, :strict) do
334+
with_error_modes(:lax, :strict) do
335335
refute_nil(Template.parse(template))
336336
end
337337

338-
with_error_mode(:rigid) do
338+
with_error_modes(:rigid) do
339339
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
340340
assert_match(/Unexpected character =/, error.message)
341341
end

0 commit comments

Comments
 (0)