diff --git a/.rubocop.yml b/.rubocop.yml index f21c47c..ac76097 100644 --- a/.rubocop.yml +++ b/.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 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 38b45a9..bfde39d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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 diff --git a/example/server/liquid_servlet.rb b/example/server/liquid_servlet.rb index 40d491e..b2bf515 100644 --- a/example/server/liquid_servlet.rb +++ b/example/server/liquid_servlet.rb @@ -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) diff --git a/lib/liquid/i18n.rb b/lib/liquid/i18n.rb index 3657c22..e998d58 100644 --- a/lib/liquid/i18n.rb +++ b/lib/liquid/i18n.rb @@ -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) diff --git a/test/integration/context_test.rb b/test/integration/context_test.rb index 2176fe0..cf83348 100644 --- a/test/integration/context_test.rb +++ b/test/integration/context_test.rb @@ -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 diff --git a/test/integration/drop_test.rb b/test/integration/drop_test.rb index a1b0c3f..d2ee2d7 100644 --- a/test/integration/drop_test.rb +++ b/test/integration/drop_test.rb @@ -19,7 +19,6 @@ class ContextDrop < Liquid::Drop end class ProductDrop < Liquid::Drop - class TextDrop < Liquid::Drop def array ['text1', 'text2'] diff --git a/test/integration/error_handling_test.rb b/test/integration/error_handling_test.rb index 54922ca..44f2a1d 100644 --- a/test/integration/error_handling_test.rb +++ b/test/integration/error_handling_test.rb @@ -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 diff --git a/test/integration/filter_test.rb b/test/integration/filter_test.rb index e346444..cf407bf 100644 --- a/test/integration/filter_test.rb +++ b/test/integration/filter_test.rb @@ -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 diff --git a/test/integration/output_test.rb b/test/integration/output_test.rb index eb1248f..f32a0a2 100644 --- a/test/integration/output_test.rb +++ b/test/integration/output_test.rb @@ -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 = %( 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_variable_args text = %( {{ car.gm | add_tag : 'span', car.bmw}} ) 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_pipings text = %( {{ best_cars | cite_funny | paragraph }} ) expected = %(

LOL: bmw

) - 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 = %( Typo ) - assert_equal expected, Template.parse(text).render!(@assigns, :filters => [FunnyFilter]) + assert_equal expected, Template.parse(text).render!(@assigns, filters: [FunnyFilter]) end end # OutputTest diff --git a/test/integration/parsing_quirks_test.rb b/test/integration/parsing_quirks_test.rb index 6f45a45..3531318 100644 --- a/test/integration/parsing_quirks_test.rb +++ b/test/integration/parsing_quirks_test.rb @@ -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 diff --git a/test/integration/render_profiling_test.rb b/test/integration/render_profiling_test.rb index d43a20b..d0111e7 100644 --- a/test/integration/render_profiling_test.rb +++ b/test/integration/render_profiling_test.rb @@ -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 diff --git a/test/integration/security_test.rb b/test/integration/security_test.rb index 033a953..c5c819f 100644 --- a/test/integration/security_test.rb +++ b/test/integration/security_test.rb @@ -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 diff --git a/test/integration/tags/break_tag_test.rb b/test/integration/tags/break_tag_test.rb index 6de955a..0fbde83 100644 --- a/test/integration/tags/break_tag_test.rb +++ b/test/integration/tags/break_tag_test.rb @@ -12,5 +12,4 @@ class BreakTagTest < Minitest::Test assert_template_result(expected, markup, assigns) end - end diff --git a/test/integration/tags/continue_tag_test.rb b/test/integration/tags/continue_tag_test.rb index 4386cac..ce4c158 100644 --- a/test/integration/tags/continue_tag_test.rb +++ b/test/integration/tags/continue_tag_test.rb @@ -12,5 +12,4 @@ class ContinueTagTest < Minitest::Test assert_template_result(expected, markup, assigns) end - end diff --git a/test/integration/tags/include_tag_test.rb b/test/integration/tags/include_tag_test.rb index 613524d..87dfe80 100644 --- a/test/integration/tags/include_tag_test.rb +++ b/test/integration/tags/include_tag_test.rb @@ -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 diff --git a/test/integration/tags/increment_tag_test.rb b/test/integration/tags/increment_tag_test.rb index 08bbeae..97c51ac 100644 --- a/test/integration/tags/increment_tag_test.rb +++ b/test/integration/tags/increment_tag_test.rb @@ -20,5 +20,4 @@ class IncrementTagTest < Minitest::Test '{%increment port %} {%decrement port%} ' \ '{%decrement starboard %}', { 'port' => 1, 'starboard' => 5 }) end - end diff --git a/test/integration/tags/standard_tag_test.rb b/test/integration/tags/standard_tag_test.rb index 43b9ac1..4b4703a 100644 --- a/test/integration/tags/standard_tag_test.rb +++ b/test/integration/tags/standard_tag_test.rb @@ -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 diff --git a/test/integration/variable_test.rb b/test/integration/variable_test.rb index e8e4f00..716f426 100644 --- a/test/integration/variable_test.rb +++ b/test/integration/variable_test.rb @@ -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 diff --git a/test/test_helper.rb b/test/test_helper.rb index e0f988c..15d8d51 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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 - diff --git a/test/unit/condition_unit_test.rb b/test/unit/condition_unit_test.rb index 4ada433..1435995 100644 --- a/test/unit/condition_unit_test.rb +++ b/test/unit/condition_unit_test.rb @@ -151,5 +151,4 @@ class ConditionUnitTest < Minitest::Test Condition.new(left, op, right).evaluate(@context || Liquid::Context.new) end end - end # ConditionTest diff --git a/test/unit/context_unit_test.rb b/test/unit/context_unit_test.rb index a90a9cd..04010a4 100644 --- a/test/unit/context_unit_test.rb +++ b/test/unit/context_unit_test.rb @@ -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 diff --git a/test/unit/i18n_unit_test.rb b/test/unit/i18n_unit_test.rb index 867a9ca..b57500e 100644 --- a/test/unit/i18n_unit_test.rb +++ b/test/unit/i18n_unit_test.rb @@ -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 diff --git a/test/unit/strainer_unit_test.rb b/test/unit/strainer_unit_test.rb index 0f970da..ef7ac08 100644 --- a/test/unit/strainer_unit_test.rb +++ b/test/unit/strainer_unit_test.rb @@ -65,5 +65,4 @@ class StrainerUnitTest < Minitest::Test assert_kind_of b, strainer assert_kind_of Liquid::StandardFilters, strainer end - end # StrainerTest diff --git a/test/unit/template_unit_test.rb b/test/unit/template_unit_test.rb index 3d63c09..42cc613 100644 --- a/test/unit/template_unit_test.rb +++ b/test/unit/template_unit_test.rb @@ -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 diff --git a/test/unit/variable_unit_test.rb b/test/unit/variable_unit_test.rb index 17fc8de..5119b2d 100644 --- a/test/unit/variable_unit_test.rb +++ b/test/unit/variable_unit_test.rb @@ -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