mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
clean up some rubocop stuff
This commit is contained in:
12
.rubocop.yml
12
.rubocop.yml
@@ -8,6 +8,15 @@ AllCops:
|
||||
Lint/AssignmentInCondition:
|
||||
Enabled: false
|
||||
|
||||
Lint/AmbiguousOperator:
|
||||
Enabled: false
|
||||
|
||||
Lint/AmbiguousRegexpLiteral:
|
||||
Enabled: false
|
||||
|
||||
Lint/ParenthesesAsGroupedExpression:
|
||||
Enabled: false
|
||||
|
||||
Lint/UnusedBlockArgument:
|
||||
Enabled: false
|
||||
|
||||
@@ -20,6 +29,9 @@ Style/SingleLineBlockParams:
|
||||
Style/StringLiteralsInInterpolation:
|
||||
Enabled: false
|
||||
|
||||
Style/AndOr:
|
||||
Enabled: false
|
||||
|
||||
Style/SignalException:
|
||||
Enabled: false
|
||||
|
||||
|
||||
@@ -1,22 +1,10 @@
|
||||
# This configuration was generated by `rubocop --auto-gen-config`
|
||||
# on 2015-06-04 11:55:03 -0400 using RuboCop version 0.31.0.
|
||||
# on 2015-06-04 12:55:39 -0400 using RuboCop version 0.31.0.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
# versions of RuboCop, may require this file to be generated again.
|
||||
|
||||
# Offense count: 2
|
||||
Lint/AmbiguousOperator:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 5
|
||||
Lint/AmbiguousRegexpLiteral:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 4
|
||||
Lint/ParenthesesAsGroupedExpression:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 11
|
||||
# Cop supports --auto-correct.
|
||||
Lint/UnusedMethodArgument:
|
||||
@@ -47,7 +35,7 @@ Metrics/ClassLength:
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 15
|
||||
|
||||
# Offense count: 554
|
||||
# Offense count: 550
|
||||
# Configuration parameters: AllowURI, URISchemes.
|
||||
Metrics/LineLength:
|
||||
Max: 294
|
||||
@@ -70,39 +58,15 @@ Metrics/PerceivedComplexity:
|
||||
Style/AccessorMethodName:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/AndOr:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
||||
Style/BlockDelimiters:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
Style/DoubleNegation:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 9
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/EmptyLinesAroundClassBody:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 3
|
||||
# Configuration parameters: MinBodyLength.
|
||||
Style/GuardClause:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 62
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
|
||||
Style/HashSyntax:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 4
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
Style/MethodName:
|
||||
@@ -122,11 +86,6 @@ Style/Next:
|
||||
Style/PredicateName:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/RedundantException:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
Style/RescueModifier:
|
||||
Enabled: false
|
||||
@@ -136,8 +95,3 @@ Style/RescueModifier:
|
||||
# Configuration parameters: AllowAsExpressionSeparator.
|
||||
Style/Semicolon:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/SpecialGlobalVars:
|
||||
Enabled: false
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class LiquidServlet < WEBrick::HTTPServlet::AbstractServlet
|
||||
|
||||
def do_GET(req, res)
|
||||
handle(:get, req, res)
|
||||
end
|
||||
@@ -20,7 +19,7 @@ class LiquidServlet < WEBrick::HTTPServlet::AbstractServlet
|
||||
|
||||
@response['Content-Type'] = "text/html"
|
||||
@response.status = 200
|
||||
@response.body = Liquid::Template.parse(read_template).render(@assigns, :filters => [ProductsFilter])
|
||||
@response.body = Liquid::Template.parse(read_template).render(@assigns, filters: [ProductsFilter])
|
||||
end
|
||||
|
||||
def read_template(filename = @action)
|
||||
|
||||
@@ -24,10 +24,10 @@ module Liquid
|
||||
private
|
||||
|
||||
def interpolate(name, vars)
|
||||
name.gsub(/%\{(\w+)\}/) {
|
||||
name.gsub(/%\{(\w+)\}/) do
|
||||
# raise TranslationError, "Undefined key #{$1} for interpolation in translation #{name}" unless vars[$1.to_sym]
|
||||
"#{vars[$1.to_sym]}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def deep_fetch_translation(name)
|
||||
|
||||
@@ -18,7 +18,7 @@ class ContextTest < Minitest::Test
|
||||
|
||||
with_global_filter(global) do
|
||||
assert_equal 'Global test', Template.parse("{{'test' | notice }}").render!
|
||||
assert_equal 'Local test', Template.parse("{{'test' | notice }}").render!({}, :filters => [local])
|
||||
assert_equal 'Local test', Template.parse("{{'test' | notice }}").render!({}, filters: [local])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ class ContextDrop < Liquid::Drop
|
||||
end
|
||||
|
||||
class ProductDrop < Liquid::Drop
|
||||
|
||||
class TextDrop < Liquid::Drop
|
||||
def array
|
||||
['text1', 'text2']
|
||||
|
||||
@@ -75,7 +75,7 @@ class ErrorHandlingTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_lax_unrecognized_operator
|
||||
template = Liquid::Template.parse(' {% if 1 =! 2 %}ok{% endif %} ', :error_mode => :lax)
|
||||
template = Liquid::Template.parse(' {% if 1 =! 2 %}ok{% endif %} ', error_mode: :lax)
|
||||
assert_equal ' Liquid error: Unknown operator =! ', template.render
|
||||
assert_equal 1, template.errors.size
|
||||
assert_equal Liquid::ArgumentError, template.errors.first.class
|
||||
@@ -90,7 +90,7 @@ class ErrorHandlingTest < Minitest::Test
|
||||
|
||||
bla
|
||||
),
|
||||
:line_numbers => true
|
||||
line_numbers: true
|
||||
)
|
||||
end
|
||||
|
||||
@@ -105,8 +105,8 @@ class ErrorHandlingTest < Minitest::Test
|
||||
|
||||
bla
|
||||
',
|
||||
:error_mode => :warn,
|
||||
:line_numbers => true
|
||||
error_mode: :warn,
|
||||
line_numbers: true
|
||||
)
|
||||
|
||||
assert_equal ['Liquid syntax error (line 4): Unexpected character = in "1 =! 2"'],
|
||||
@@ -122,8 +122,8 @@ class ErrorHandlingTest < Minitest::Test
|
||||
|
||||
bla
|
||||
',
|
||||
:error_mode => :strict,
|
||||
:line_numbers => true
|
||||
error_mode: :strict,
|
||||
line_numbers: true
|
||||
)
|
||||
end
|
||||
|
||||
@@ -141,7 +141,7 @@ class ErrorHandlingTest < Minitest::Test
|
||||
|
||||
bla
|
||||
',
|
||||
:line_numbers => true
|
||||
line_numbers: true
|
||||
)
|
||||
end
|
||||
|
||||
@@ -150,18 +150,18 @@ class ErrorHandlingTest < Minitest::Test
|
||||
|
||||
def test_strict_error_messages
|
||||
err = assert_raises(SyntaxError) do
|
||||
Liquid::Template.parse(' {% if 1 =! 2 %}ok{% endif %} ', :error_mode => :strict)
|
||||
Liquid::Template.parse(' {% if 1 =! 2 %}ok{% endif %} ', error_mode: :strict)
|
||||
end
|
||||
assert_equal 'Liquid syntax error: Unexpected character = in "1 =! 2"', err.message
|
||||
|
||||
err = assert_raises(SyntaxError) do
|
||||
Liquid::Template.parse('{{%%%}}', :error_mode => :strict)
|
||||
Liquid::Template.parse('{{%%%}}', error_mode: :strict)
|
||||
end
|
||||
assert_equal 'Liquid syntax error: Unexpected character % in "{{%%%}}"', err.message
|
||||
end
|
||||
|
||||
def test_warnings
|
||||
template = Liquid::Template.parse('{% if ~~~ %}{{%%%}}{% else %}{{ hello. }}{% endif %}', :error_mode => :warn)
|
||||
template = Liquid::Template.parse('{% if ~~~ %}{{%%%}}{% else %}{{ hello. }}{% endif %}', error_mode: :warn)
|
||||
assert_equal 3, template.warnings.size
|
||||
assert_equal 'Unexpected character ~ in "~~~"', template.warnings[0].to_s(false)
|
||||
assert_equal 'Unexpected character % in "{{%%%}}"', template.warnings[1].to_s(false)
|
||||
@@ -170,7 +170,7 @@ class ErrorHandlingTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_warning_line_numbers
|
||||
template = Liquid::Template.parse("{% if ~~~ %}\n{{%%%}}{% else %}\n{{ hello. }}{% endif %}", :error_mode => :warn, :line_numbers => true)
|
||||
template = Liquid::Template.parse("{% if ~~~ %}\n{{%%%}}{% else %}\n{{ hello. }}{% endif %}", error_mode: :warn, line_numbers: true)
|
||||
assert_equal 'Liquid syntax error (line 1): Unexpected character ~ in "~~~"', template.warnings[0].message
|
||||
assert_equal 'Liquid syntax error (line 2): Unexpected character % in "{{%%%}}"', template.warnings[1].message
|
||||
assert_equal 'Liquid syntax error (line 3): Expected id but found end_of_string in "{{ hello. }}"', template.warnings[2].message
|
||||
|
||||
@@ -136,7 +136,7 @@ class FiltersTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_override_object_method_in_filter
|
||||
assert_equal "tap overridden", Template.parse("{{var | tap}}").render!({ 'var' => 1000 }, :filters => [OverrideObjectMethodFilter])
|
||||
assert_equal "tap overridden", Template.parse("{{var | tap}}").render!({ 'var' => 1000 }, filters: [OverrideObjectMethodFilter])
|
||||
|
||||
# tap still treated as a non-existent filter
|
||||
assert_equal "1000", Template.parse("{{var | tap}}").render!({ 'var' => 1000 })
|
||||
@@ -149,8 +149,8 @@ class FiltersInTemplate < Minitest::Test
|
||||
def test_local_global
|
||||
with_global_filter(MoneyFilter) do
|
||||
assert_equal " 1000$ ", Template.parse("{{1000 | money}}").render!(nil, nil)
|
||||
assert_equal " 1000$ CAD ", Template.parse("{{1000 | money}}").render!(nil, :filters => CanadianMoneyFilter)
|
||||
assert_equal " 1000$ CAD ", Template.parse("{{1000 | money}}").render!(nil, :filters => [CanadianMoneyFilter])
|
||||
assert_equal " 1000$ CAD ", Template.parse("{{1000 | money}}").render!(nil, filters: CanadianMoneyFilter)
|
||||
assert_equal " 1000$ CAD ", Template.parse("{{1000 | money}}").render!(nil, filters: [CanadianMoneyFilter])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -54,62 +54,62 @@ class OutputTest < Minitest::Test
|
||||
text = %( {{ car.gm | make_funny }} )
|
||||
expected = %( LOL )
|
||||
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, :filters => [FunnyFilter])
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter])
|
||||
end
|
||||
|
||||
def test_variable_piping_with_input
|
||||
text = %( {{ car.gm | cite_funny }} )
|
||||
expected = %( LOL: bad )
|
||||
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, :filters => [FunnyFilter])
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter])
|
||||
end
|
||||
|
||||
def test_variable_piping_with_args
|
||||
text = %! {{ car.gm | add_smiley : ':-(' }} !
|
||||
expected = %| bad :-( |
|
||||
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, :filters => [FunnyFilter])
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter])
|
||||
end
|
||||
|
||||
def test_variable_piping_with_no_args
|
||||
text = %( {{ car.gm | add_smiley }} )
|
||||
expected = %| bad :-) |
|
||||
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, :filters => [FunnyFilter])
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter])
|
||||
end
|
||||
|
||||
def test_multiple_variable_piping_with_args
|
||||
text = %! {{ car.gm | add_smiley : ':-(' | add_smiley : ':-('}} !
|
||||
expected = %| bad :-( :-( |
|
||||
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, :filters => [FunnyFilter])
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter])
|
||||
end
|
||||
|
||||
def test_variable_piping_with_multiple_args
|
||||
text = %( {{ car.gm | add_tag : 'span', 'bar'}} )
|
||||
expected = %( <span id="bar">bad</span> )
|
||||
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, :filters => [FunnyFilter])
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter])
|
||||
end
|
||||
|
||||
def test_variable_piping_with_variable_args
|
||||
text = %( {{ car.gm | add_tag : 'span', car.bmw}} )
|
||||
expected = %( <span id="good">bad</span> )
|
||||
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, :filters => [FunnyFilter])
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter])
|
||||
end
|
||||
|
||||
def test_multiple_pipings
|
||||
text = %( {{ best_cars | cite_funny | paragraph }} )
|
||||
expected = %( <p>LOL: bmw</p> )
|
||||
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, :filters => [FunnyFilter])
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter])
|
||||
end
|
||||
|
||||
def test_link_to
|
||||
text = %( {{ 'Typo' | link_to: 'http://typo.leetsoft.com' }} )
|
||||
expected = %( <a href="http://typo.leetsoft.com">Typo</a> )
|
||||
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, :filters => [FunnyFilter])
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter])
|
||||
end
|
||||
end # OutputTest
|
||||
|
||||
@@ -62,9 +62,9 @@ class ParsingQuirksTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_no_error_on_lax_empty_filter
|
||||
assert Template.parse("{{test |a|b|}}", :error_mode => :lax)
|
||||
assert Template.parse("{{test}}", :error_mode => :lax)
|
||||
assert Template.parse("{{|test|}}", :error_mode => :lax)
|
||||
assert Template.parse("{{test |a|b|}}", error_mode: :lax)
|
||||
assert Template.parse("{{test}}", error_mode: :lax)
|
||||
assert Template.parse("{{|test|}}", error_mode: :lax)
|
||||
end
|
||||
|
||||
def test_meaningless_parens_lax
|
||||
@@ -115,5 +115,4 @@ class ParsingQuirksTest < Minitest::Test
|
||||
assert_template_result('12345', "{% for i in (1...5) %}{{ i }}{% endfor %}")
|
||||
end
|
||||
end
|
||||
|
||||
end # ParsingQuirksTest
|
||||
|
||||
@@ -21,7 +21,7 @@ class RenderProfilingTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_parse_makes_available_simple_profiling
|
||||
t = Template.parse("{{ 'a string' | upcase }}", :profile => true)
|
||||
t = Template.parse("{{ 'a string' | upcase }}", profile: true)
|
||||
t.render!
|
||||
|
||||
assert_equal 1, t.profiler.length
|
||||
@@ -31,14 +31,14 @@ class RenderProfilingTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_render_ignores_raw_strings_when_profiling
|
||||
t = Template.parse("This is raw string\nstuff\nNewline", :profile => true)
|
||||
t = Template.parse("This is raw string\nstuff\nNewline", profile: true)
|
||||
t.render!
|
||||
|
||||
assert_equal 0, t.profiler.length
|
||||
end
|
||||
|
||||
def test_profiling_includes_line_numbers_of_liquid_nodes
|
||||
t = Template.parse("{{ 'a string' | upcase }}\n{% increment test %}", :profile => true)
|
||||
t = Template.parse("{{ 'a string' | upcase }}\n{% increment test %}", profile: true)
|
||||
t.render!
|
||||
assert_equal 2, t.profiler.length
|
||||
|
||||
@@ -49,7 +49,7 @@ class RenderProfilingTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_profiling_includes_line_numbers_of_included_partials
|
||||
t = Template.parse("{% include 'a_template' %}", :profile => true)
|
||||
t = Template.parse("{% include 'a_template' %}", profile: true)
|
||||
t.render!
|
||||
|
||||
included_children = t.profiler[0].children
|
||||
@@ -61,7 +61,7 @@ class RenderProfilingTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_profiling_times_the_rendering_of_tokens
|
||||
t = Template.parse("{% include 'a_template' %}", :profile => true)
|
||||
t = Template.parse("{% include 'a_template' %}", profile: true)
|
||||
t.render!
|
||||
|
||||
node = t.profiler[0]
|
||||
@@ -69,14 +69,14 @@ class RenderProfilingTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_profiling_times_the_entire_render
|
||||
t = Template.parse("{% include 'a_template' %}", :profile => true)
|
||||
t = Template.parse("{% include 'a_template' %}", profile: true)
|
||||
t.render!
|
||||
|
||||
assert t.profiler.total_render_time >= 0, "Total render time was not calculated"
|
||||
end
|
||||
|
||||
def test_profiling_uses_include_to_mark_children
|
||||
t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}", :profile => true)
|
||||
t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}", profile: true)
|
||||
t.render!
|
||||
|
||||
include_node = t.profiler[1]
|
||||
@@ -84,7 +84,7 @@ class RenderProfilingTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_profiling_marks_children_with_the_name_of_included_partial
|
||||
t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}", :profile => true)
|
||||
t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}", profile: true)
|
||||
t.render!
|
||||
|
||||
include_node = t.profiler[1]
|
||||
@@ -94,7 +94,7 @@ class RenderProfilingTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_profiling_supports_multiple_templates
|
||||
t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}\n{% include 'b_template' %}", :profile => true)
|
||||
t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}\n{% include 'b_template' %}", profile: true)
|
||||
t.render!
|
||||
|
||||
a_template = t.profiler[1]
|
||||
@@ -109,7 +109,7 @@ class RenderProfilingTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_profiling_supports_rendering_the_same_partial_multiple_times
|
||||
t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}\n{% include 'a_template' %}", :profile => true)
|
||||
t = Template.parse("{{ 'a string' | upcase }}\n{% include 'a_template' %}\n{% include 'a_template' %}", profile: true)
|
||||
t.render!
|
||||
|
||||
a_template1 = t.profiler[1]
|
||||
@@ -124,7 +124,7 @@ class RenderProfilingTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_can_iterate_over_each_profiling_entry
|
||||
t = Template.parse("{{ 'a string' | upcase }}\n{% increment test %}", :profile => true)
|
||||
t = Template.parse("{{ 'a string' | upcase }}\n{% increment test %}", profile: true)
|
||||
t.render!
|
||||
|
||||
timing_count = 0
|
||||
@@ -136,7 +136,7 @@ class RenderProfilingTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_profiling_marks_children_of_if_blocks
|
||||
t = Template.parse("{% if true %} {% increment test %} {{ test }} {% endif %}", :profile => true)
|
||||
t = Template.parse("{% if true %} {% increment test %} {{ test }} {% endif %}", profile: true)
|
||||
t.render!
|
||||
|
||||
assert_equal 1, t.profiler.length
|
||||
@@ -144,7 +144,7 @@ class RenderProfilingTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_profiling_marks_children_of_for_blocks
|
||||
t = Template.parse("{% for item in collection %} {{ item }} {% endfor %}", :profile => true)
|
||||
t = Template.parse("{% for item in collection %} {{ item }} {% endfor %}", profile: true)
|
||||
t.render!({ "collection" => ["one", "two"] })
|
||||
|
||||
assert_equal 1, t.profiler.length
|
||||
|
||||
@@ -34,7 +34,7 @@ class SecurityTest < Minitest::Test
|
||||
text = %( {{ '1+1' | add_one | instance_eval }} )
|
||||
expected = %( 1+1 + 1 )
|
||||
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, :filters => SecurityFilter)
|
||||
assert_equal expected, Template.parse(text).render!(@assigns, filters: SecurityFilter)
|
||||
end
|
||||
|
||||
def test_does_not_add_filters_to_symbol_table
|
||||
|
||||
@@ -12,5 +12,4 @@ class BreakTagTest < Minitest::Test
|
||||
|
||||
assert_template_result(expected, markup, assigns)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -12,5 +12,4 @@ class ContinueTagTest < Minitest::Test
|
||||
|
||||
assert_template_result(expected, markup, assigns)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -77,7 +77,7 @@ class IncludeTagTest < Minitest::Test
|
||||
|
||||
def test_include_tag_looks_for_file_system_in_registers_first
|
||||
assert_equal 'from OtherFileSystem',
|
||||
Template.parse("{% include 'pick_a_source' %}").render!({}, :registers => { :file_system => OtherFileSystem.new })
|
||||
Template.parse("{% include 'pick_a_source' %}").render!({}, registers: { file_system: OtherFileSystem.new })
|
||||
end
|
||||
|
||||
def test_include_tag_with
|
||||
@@ -153,18 +153,18 @@ class IncludeTagTest < Minitest::Test
|
||||
def test_include_tag_caches_second_read_of_same_partial
|
||||
file_system = CountingFileSystem.new
|
||||
assert_equal 'from CountingFileSystemfrom CountingFileSystem',
|
||||
Template.parse("{% include 'pick_a_source' %}{% include 'pick_a_source' %}").render!({}, :registers => { :file_system => file_system })
|
||||
Template.parse("{% include 'pick_a_source' %}{% include 'pick_a_source' %}").render!({}, registers: { file_system: file_system })
|
||||
assert_equal 1, file_system.count
|
||||
end
|
||||
|
||||
def test_include_tag_doesnt_cache_partials_across_renders
|
||||
file_system = CountingFileSystem.new
|
||||
assert_equal 'from CountingFileSystem',
|
||||
Template.parse("{% include 'pick_a_source' %}").render!({}, :registers => { :file_system => file_system })
|
||||
Template.parse("{% include 'pick_a_source' %}").render!({}, registers: { file_system: file_system })
|
||||
assert_equal 1, file_system.count
|
||||
|
||||
assert_equal 'from CountingFileSystem',
|
||||
Template.parse("{% include 'pick_a_source' %}").render!({}, :registers => { :file_system => file_system })
|
||||
Template.parse("{% include 'pick_a_source' %}").render!({}, registers: { file_system: file_system })
|
||||
assert_equal 2, file_system.count
|
||||
end
|
||||
|
||||
|
||||
@@ -20,5 +20,4 @@ class IncrementTagTest < Minitest::Test
|
||||
'{%increment port %} {%decrement port%} ' \
|
||||
'{%decrement starboard %}', { 'port' => 1, 'starboard' => 5 })
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -271,7 +271,7 @@ class StandardTagTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_size_of_hash
|
||||
assigns = { "hash" => { :a => 1, :b => 2, :c => 3, :d => 4 } }
|
||||
assigns = { "hash" => { a: 1, b: 2, c: 3, d: 4 } }
|
||||
assert_template_result('hash has 4 elements', "hash has {{ hash.size }} elements", assigns)
|
||||
end
|
||||
|
||||
|
||||
@@ -70,9 +70,9 @@ class VariableTest < Minitest::Test
|
||||
assigns['test'] = 'Tobi'
|
||||
assert_equal 'Hello Tobi', template.render!(assigns)
|
||||
assigns.delete('test')
|
||||
e = assert_raises(RuntimeError) {
|
||||
e = assert_raises(RuntimeError) do
|
||||
template.render!(assigns)
|
||||
}
|
||||
end
|
||||
assert_equal "Unknown variable 'test'", e.message
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ ENV["MT_NO_EXPECTATIONS"] = "1"
|
||||
require 'minitest/autorun'
|
||||
require 'spy/integration'
|
||||
|
||||
$:.unshift(File.join(File.expand_path(__dir__), '..', 'lib'))
|
||||
$LOAD_PATH.unshift(File.join(File.expand_path(__dir__), '..', 'lib'))
|
||||
require 'liquid.rb'
|
||||
require 'liquid/profiler'
|
||||
|
||||
@@ -43,9 +43,9 @@ module Minitest
|
||||
end
|
||||
|
||||
def assert_match_syntax_error(match, template, assigns = {})
|
||||
exception = assert_raises(Liquid::SyntaxError) {
|
||||
exception = assert_raises(Liquid::SyntaxError) do
|
||||
Template.parse(template).render(assigns)
|
||||
}
|
||||
end
|
||||
assert_match match, exception.message
|
||||
end
|
||||
|
||||
@@ -103,11 +103,10 @@ class ErrorDrop < Liquid::Drop
|
||||
end
|
||||
|
||||
def runtime_error
|
||||
raise RuntimeError, 'runtime error'
|
||||
raise 'runtime error'
|
||||
end
|
||||
|
||||
def exception
|
||||
raise Exception, 'exception'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -151,5 +151,4 @@ class ConditionUnitTest < Minitest::Test
|
||||
Condition.new(left, op, right).evaluate(@context || Liquid::Context.new)
|
||||
end
|
||||
end
|
||||
|
||||
end # ConditionTest
|
||||
|
||||
@@ -462,10 +462,9 @@ class ContextUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_context_initialization_with_a_proc_in_environment
|
||||
contx = Context.new([:test => ->(c) { c['poutine'] }], { :test => :foo })
|
||||
contx = Context.new([test: ->(c) { c['poutine'] }], { test: :foo })
|
||||
|
||||
assert contx
|
||||
assert_nil contx['poutine']
|
||||
end
|
||||
|
||||
end # ContextTest
|
||||
|
||||
@@ -16,7 +16,7 @@ class I18nUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_single_string_interpolation
|
||||
assert_equal "something different", @i18n.translate("whatever", :something => "different")
|
||||
assert_equal "something different", @i18n.translate("whatever", something: "different")
|
||||
end
|
||||
|
||||
# def test_raises_translation_error_on_undefined_interpolation_key
|
||||
|
||||
@@ -65,5 +65,4 @@ class StrainerUnitTest < Minitest::Test
|
||||
assert_kind_of b, strainer
|
||||
assert_kind_of Liquid::StandardFilters, strainer
|
||||
end
|
||||
|
||||
end # StrainerTest
|
||||
|
||||
@@ -11,7 +11,7 @@ class TemplateUnitTest < Minitest::Test
|
||||
|
||||
def test_sets_default_localization_in_context_with_quick_initialization
|
||||
t = Template.new
|
||||
t.parse('{%comment%}{%endcomment%}', :locale => I18n.new(fixture("en_locale.yml")))
|
||||
t.parse('{%comment%}{%endcomment%}', locale: I18n.new(fixture("en_locale.yml")))
|
||||
|
||||
locale = t.root.nodelist[0].options[:locale]
|
||||
assert_instance_of I18n, locale
|
||||
|
||||
@@ -71,7 +71,7 @@ class VariableUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_symbol
|
||||
var = Variable.new("http://disney.com/logo.gif | image: 'med' ", :error_mode => :lax)
|
||||
var = Variable.new("http://disney.com/logo.gif | image: 'med' ", error_mode: :lax)
|
||||
assert_equal VariableLookup.new('http://disney.com/logo.gif'), var.name
|
||||
assert_equal [['image', ['med']]], var.filters
|
||||
end
|
||||
@@ -130,7 +130,7 @@ class VariableUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_lax_filter_argument_parsing
|
||||
var = Variable.new(%( number_of_comments | pluralize: 'comment': 'comments' ), :error_mode => :lax)
|
||||
var = Variable.new(%( number_of_comments | pluralize: 'comment': 'comments' ), error_mode: :lax)
|
||||
assert_equal VariableLookup.new('number_of_comments'), var.name
|
||||
assert_equal [['pluralize', ['comment', 'comments']]], var.filters
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user