clean up some rubocop stuff

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