From 7a23f46fabcfb14d37db00744fa055529952e09b Mon Sep 17 00:00:00 2001 From: Thierry Joyal Date: Fri, 4 Mar 2022 09:10:38 -0500 Subject: [PATCH 1/2] ContextTest: Cleanup global variable assignments --- test/integration/context_test.rb | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/test/integration/context_test.rb b/test/integration/context_test.rb index a6ef3e58..874cc8bd 100644 --- a/test/integration/context_test.rb +++ b/test/integration/context_test.rb @@ -405,45 +405,42 @@ class ContextTest < Minitest::Test end def test_lambda_is_called_once + @global = 0 + @context['callcount'] = proc { - @global ||= 0 - @global += 1 + @global += 1 @global.to_s } assert_equal('1', @context['callcount']) assert_equal('1', @context['callcount']) assert_equal('1', @context['callcount']) - - @global = nil end def test_nested_lambda_is_called_once + @global = 0 + @context['callcount'] = { "lambda" => proc { - @global ||= 0 - @global += 1 + @global += 1 @global.to_s } } assert_equal('1', @context['callcount.lambda']) assert_equal('1', @context['callcount.lambda']) assert_equal('1', @context['callcount.lambda']) - - @global = nil end def test_lambda_in_array_is_called_once + @global = 0 + @context['callcount'] = [1, 2, proc { - @global ||= 0 - @global += 1 + @global += 1 @global.to_s }, 4, 5] assert_equal('1', @context['callcount[2]']) assert_equal('1', @context['callcount[2]']) assert_equal('1', @context['callcount[2]']) - - @global = nil end def test_access_to_context_from_proc From 0f5220c39168074f98e4042f473f8860d3c7735f Mon Sep 17 00:00:00 2001 From: Thierry Joyal Date: Fri, 4 Mar 2022 09:14:57 -0500 Subject: [PATCH 2/2] ContextTest: Classes to use appropriate ancestor --- test/integration/context_test.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration/context_test.rb b/test/integration/context_test.rb index 874cc8bd..58f1c331 100644 --- a/test/integration/context_test.rb +++ b/test/integration/context_test.rb @@ -24,7 +24,7 @@ class ContextSensitiveDrop < Liquid::Drop end end -class Category < Liquid::Drop +class Category attr_accessor :name def initialize(name) @@ -36,8 +36,9 @@ class Category < Liquid::Drop end end -class CategoryDrop +class CategoryDrop < Liquid::Drop attr_accessor :category, :context + def initialize(category) @category = category end