mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Add ForceEqualSignAlignment to .rubocop.yml (#1190)
* Add ForceEqualSignAlignment to .rubocop.yml * Revert ForceEqualSignAlignment cop * Update method alignment * Undo addition of whitespace to improve readability * Fix missing alignment
This commit is contained in:
committed by
Mike Angell
parent
3784020a8d
commit
e83b1e4159
@@ -63,7 +63,7 @@ class BlockUnitTest < Minitest::Test
|
||||
|
||||
assert_equal 'hello', template.render
|
||||
|
||||
buf = +''
|
||||
buf = +''
|
||||
output = template.render({}, output: buf)
|
||||
assert_equal 'hello', output
|
||||
assert_equal 'hello', buf
|
||||
@@ -81,7 +81,7 @@ class BlockUnitTest < Minitest::Test
|
||||
|
||||
assert_equal 'foohellobar', template.render
|
||||
|
||||
buf = +''
|
||||
buf = +''
|
||||
output = template.render({}, output: buf)
|
||||
assert_equal 'foohellobar', output
|
||||
assert_equal 'foohellobar', buf
|
||||
|
||||
@@ -75,9 +75,9 @@ class ConditionUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_contains_works_on_arrays
|
||||
@context = Liquid::Context.new
|
||||
@context = Liquid::Context.new
|
||||
@context['array'] = [1, 2, 3, 4, 5]
|
||||
array_expr = VariableLookup.new("array")
|
||||
array_expr = VariableLookup.new("array")
|
||||
|
||||
assert_evaluates_false(array_expr, 'contains', 0)
|
||||
assert_evaluates_true(array_expr, 'contains', 1)
|
||||
@@ -142,7 +142,7 @@ class ConditionUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_left_or_right_may_contain_operators
|
||||
@context = Liquid::Context.new
|
||||
@context = Liquid::Context.new
|
||||
@context['one'] = @context['another'] = "gnomeslab-and-or-liquid"
|
||||
|
||||
assert_evaluates_true(VariableLookup.new("one"), '==', VariableLookup.new("another"))
|
||||
|
||||
@@ -46,7 +46,7 @@ end
|
||||
class CounterDrop < Liquid::Drop
|
||||
def count
|
||||
@count ||= 0
|
||||
@count += 1
|
||||
@count += 1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -55,9 +55,9 @@ class ArrayLike
|
||||
end
|
||||
|
||||
def [](index)
|
||||
@counts ||= []
|
||||
@counts ||= []
|
||||
@counts[index] ||= 0
|
||||
@counts[index] += 1
|
||||
@counts[index] += 1
|
||||
end
|
||||
|
||||
def to_liquid
|
||||
@@ -265,7 +265,7 @@ class ContextUnitTest < Minitest::Test
|
||||
|
||||
def test_access_hashes_with_hash_notation
|
||||
@context['products'] = { 'count' => 5, 'tags' => ['deepsnow', 'freestyle'] }
|
||||
@context['product'] = { 'variants' => [{ 'title' => 'draft151cm' }, { 'title' => 'element151cm' }] }
|
||||
@context['product'] = { 'variants' => [{ 'title' => 'draft151cm' }, { 'title' => 'element151cm' }] }
|
||||
|
||||
assert_equal(5, @context['products["count"]'])
|
||||
assert_equal('deepsnow', @context['products["tags"][0]'])
|
||||
@@ -285,8 +285,8 @@ class ContextUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_access_hashes_with_hash_access_variables
|
||||
@context['var'] = 'tags'
|
||||
@context['nested'] = { 'var' => 'tags' }
|
||||
@context['var'] = 'tags'
|
||||
@context['nested'] = { 'var' => 'tags' }
|
||||
@context['products'] = { 'count' => 5, 'tags' => ['deepsnow', 'freestyle'] }
|
||||
|
||||
assert_equal('deepsnow', @context['products[var].first'])
|
||||
@@ -295,7 +295,7 @@ class ContextUnitTest < Minitest::Test
|
||||
|
||||
def test_hash_notation_only_for_hash_access
|
||||
@context['array'] = [1, 2, 3, 4, 5]
|
||||
@context['hash'] = { 'first' => 'Hello' }
|
||||
@context['hash'] = { 'first' => 'Hello' }
|
||||
|
||||
assert_equal(1, @context['array.first'])
|
||||
assert_nil(@context['array["first"]'])
|
||||
@@ -407,7 +407,7 @@ class ContextUnitTest < Minitest::Test
|
||||
def test_lambda_is_called_once
|
||||
@context['callcount'] = proc {
|
||||
@global ||= 0
|
||||
@global += 1
|
||||
@global += 1
|
||||
@global.to_s
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ class ContextUnitTest < Minitest::Test
|
||||
def test_nested_lambda_is_called_once
|
||||
@context['callcount'] = { "lambda" => proc {
|
||||
@global ||= 0
|
||||
@global += 1
|
||||
@global += 1
|
||||
@global.to_s
|
||||
} }
|
||||
|
||||
@@ -435,7 +435,7 @@ class ContextUnitTest < Minitest::Test
|
||||
def test_lambda_in_array_is_called_once
|
||||
@context['callcount'] = [1, 2, proc {
|
||||
@global ||= 0
|
||||
@global += 1
|
||||
@global += 1
|
||||
@global.to_s
|
||||
}, 4, 5]
|
||||
|
||||
@@ -507,15 +507,15 @@ class ContextUnitTest < Minitest::Test
|
||||
|
||||
def test_new_isolated_subcontext_inherits_static_environment
|
||||
super_context = Context.build(static_environments: { 'my_environment_value' => 'my value' })
|
||||
subcontext = super_context.new_isolated_subcontext
|
||||
subcontext = super_context.new_isolated_subcontext
|
||||
|
||||
assert_equal('my value', subcontext['my_environment_value'])
|
||||
end
|
||||
|
||||
def test_new_isolated_subcontext_inherits_resource_limits
|
||||
resource_limits = ResourceLimits.new({})
|
||||
super_context = Context.new({}, {}, {}, false, resource_limits)
|
||||
subcontext = super_context.new_isolated_subcontext
|
||||
super_context = Context.new({}, {}, {}, false, resource_limits)
|
||||
subcontext = super_context.new_isolated_subcontext
|
||||
assert_equal(resource_limits, subcontext.resource_limits)
|
||||
end
|
||||
|
||||
@@ -532,19 +532,19 @@ class ContextUnitTest < Minitest::Test
|
||||
}
|
||||
super_context = Context.new({}, {}, StaticRegisters.new(registers))
|
||||
super_context.registers[:my_register] = :my_alt_value
|
||||
subcontext = super_context.new_isolated_subcontext
|
||||
subcontext = super_context.new_isolated_subcontext
|
||||
assert_equal(:my_value, subcontext.registers[:my_register])
|
||||
end
|
||||
|
||||
def test_new_isolated_subcontext_inherits_static_registers
|
||||
super_context = Context.build(registers: { my_register: :my_value })
|
||||
subcontext = super_context.new_isolated_subcontext
|
||||
subcontext = super_context.new_isolated_subcontext
|
||||
assert_equal(:my_value, subcontext.registers[:my_register])
|
||||
end
|
||||
|
||||
def test_new_isolated_subcontext_registers_do_not_pollute_context
|
||||
super_context = Context.build(registers: { my_register: :my_value })
|
||||
subcontext = super_context.new_isolated_subcontext
|
||||
super_context = Context.build(registers: { my_register: :my_value })
|
||||
subcontext = super_context.new_isolated_subcontext
|
||||
subcontext.registers[:my_register] = :my_alt_value
|
||||
assert_equal(:my_value, super_context.registers[:my_register])
|
||||
end
|
||||
@@ -558,8 +558,8 @@ class ContextUnitTest < Minitest::Test
|
||||
|
||||
super_context = Context.new
|
||||
super_context.add_filters([my_filter])
|
||||
subcontext = super_context.new_isolated_subcontext
|
||||
template = Template.parse('{{ 123 | my_filter }}')
|
||||
subcontext = super_context.new_isolated_subcontext
|
||||
template = Template.parse('{{ 123 | my_filter }}')
|
||||
assert_equal('my filter result', template.render(subcontext))
|
||||
end
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class PartialCacheUnitTest < Minitest::Test
|
||||
|
||||
def test_reads_from_the_file_system_only_once_per_file
|
||||
file_system = StubFileSystem.new('my_partial' => 'some partial body')
|
||||
context = Liquid::Context.build(
|
||||
context = Liquid::Context.build(
|
||||
registers: { file_system: file_system }
|
||||
)
|
||||
|
||||
@@ -37,7 +37,7 @@ class PartialCacheUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_cache_state_is_stored_per_context
|
||||
parse_context = Liquid::ParseContext.new
|
||||
parse_context = Liquid::ParseContext.new
|
||||
shared_file_system = StubFileSystem.new(
|
||||
'my_partial' => 'my shared value'
|
||||
)
|
||||
@@ -71,7 +71,7 @@ class PartialCacheUnitTest < Minitest::Test
|
||||
|
||||
def test_cache_is_not_broken_when_a_different_parse_context_is_used
|
||||
file_system = StubFileSystem.new('my_partial' => 'some partial body')
|
||||
context = Liquid::Context.build(
|
||||
context = Liquid::Context.build(
|
||||
registers: { file_system: file_system }
|
||||
)
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ class StaticRegistersUnitTest < Minitest::Test
|
||||
include Liquid
|
||||
|
||||
def set
|
||||
static_register = StaticRegisters.new
|
||||
static_register[nil] = true
|
||||
static_register[1] = :one
|
||||
static_register[:one] = "one"
|
||||
static_register = StaticRegisters.new
|
||||
static_register[nil] = true
|
||||
static_register[1] = :one
|
||||
static_register[:one] = "one"
|
||||
static_register["two"] = "three"
|
||||
static_register["two"] = 3
|
||||
static_register[false] = nil
|
||||
@@ -77,10 +77,10 @@ class StaticRegistersUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def set_with_static
|
||||
static_register = StaticRegisters.new(nil => true, 1 => :one, :one => "one", "two" => 3, false => nil)
|
||||
static_register[nil] = false
|
||||
static_register = StaticRegisters.new(nil => true, 1 => :one, :one => "one", "two" => 3, false => nil)
|
||||
static_register[nil] = false
|
||||
static_register["two"] = 4
|
||||
static_register[true] = "foo"
|
||||
static_register[true] = "foo"
|
||||
|
||||
assert_equal({ nil => true, 1 => :one, :one => "one", "two" => 3, false => nil }, static_register.static)
|
||||
assert_equal({ nil => false, "two" => 4, true => "foo" }, static_register.registers)
|
||||
@@ -154,23 +154,23 @@ class StaticRegistersUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_new_static_retains_static
|
||||
static_register = StaticRegisters.new(nil => true, 1 => :one, :one => "one", "two" => 3, false => nil)
|
||||
static_register["one"] = 1
|
||||
static_register["two"] = 2
|
||||
static_register = StaticRegisters.new(nil => true, 1 => :one, :one => "one", "two" => 3, false => nil)
|
||||
static_register["one"] = 1
|
||||
static_register["two"] = 2
|
||||
static_register["three"] = 3
|
||||
|
||||
new_register = StaticRegisters.new(static_register)
|
||||
assert_equal({}, new_register.registers)
|
||||
|
||||
new_register["one"] = 4
|
||||
new_register["two"] = 5
|
||||
new_register["one"] = 4
|
||||
new_register["two"] = 5
|
||||
new_register["three"] = 6
|
||||
|
||||
newest_register = StaticRegisters.new(new_register)
|
||||
assert_equal({}, newest_register.registers)
|
||||
|
||||
newest_register["one"] = 7
|
||||
newest_register["two"] = 8
|
||||
newest_register["one"] = 7
|
||||
newest_register["two"] = 8
|
||||
newest_register["three"] = 9
|
||||
|
||||
assert_equal({ "one" => 1, "two" => 2, "three" => 3 }, static_register.registers)
|
||||
@@ -182,23 +182,23 @@ class StaticRegistersUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_multiple_instances_are_unique
|
||||
static_register = StaticRegisters.new(nil => true, 1 => :one, :one => "one", "two" => 3, false => nil)
|
||||
static_register["one"] = 1
|
||||
static_register["two"] = 2
|
||||
static_register = StaticRegisters.new(nil => true, 1 => :one, :one => "one", "two" => 3, false => nil)
|
||||
static_register["one"] = 1
|
||||
static_register["two"] = 2
|
||||
static_register["three"] = 3
|
||||
|
||||
new_register = StaticRegisters.new(foo: :bar)
|
||||
assert_equal({}, new_register.registers)
|
||||
|
||||
new_register["one"] = 4
|
||||
new_register["two"] = 5
|
||||
new_register["one"] = 4
|
||||
new_register["two"] = 5
|
||||
new_register["three"] = 6
|
||||
|
||||
newest_register = StaticRegisters.new(bar: :foo)
|
||||
assert_equal({}, newest_register.registers)
|
||||
|
||||
newest_register["one"] = 7
|
||||
newest_register["two"] = 8
|
||||
newest_register["one"] = 7
|
||||
newest_register["two"] = 8
|
||||
newest_register["three"] = 9
|
||||
|
||||
assert_equal({ "one" => 1, "two" => 2, "three" => 3 }, static_register.registers)
|
||||
@@ -210,9 +210,9 @@ class StaticRegistersUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_can_update_static_directly_and_updates_all_instances
|
||||
static_register = StaticRegisters.new(nil => true, 1 => :one, :one => "one", "two" => 3, false => nil)
|
||||
static_register["one"] = 1
|
||||
static_register["two"] = 2
|
||||
static_register = StaticRegisters.new(nil => true, 1 => :one, :one => "one", "two" => 3, false => nil)
|
||||
static_register["one"] = 1
|
||||
static_register["two"] = 2
|
||||
static_register["three"] = 3
|
||||
|
||||
new_register = StaticRegisters.new(static_register)
|
||||
@@ -220,9 +220,9 @@ class StaticRegistersUnitTest < Minitest::Test
|
||||
|
||||
assert_equal({ nil => true, 1 => :one, :one => "one", "two" => 3, false => nil }, static_register.static)
|
||||
|
||||
new_register["one"] = 4
|
||||
new_register["two"] = 5
|
||||
new_register["three"] = 6
|
||||
new_register["one"] = 4
|
||||
new_register["two"] = 5
|
||||
new_register["three"] = 6
|
||||
new_register.static["four"] = 10
|
||||
|
||||
newest_register = StaticRegisters.new(new_register)
|
||||
@@ -230,9 +230,9 @@ class StaticRegistersUnitTest < Minitest::Test
|
||||
|
||||
assert_equal({ nil => true, 1 => :one, :one => "one", "two" => 3, false => nil, "four" => 10 }, new_register.static)
|
||||
|
||||
newest_register["one"] = 7
|
||||
newest_register["two"] = 8
|
||||
newest_register["three"] = 9
|
||||
newest_register["one"] = 7
|
||||
newest_register["two"] = 8
|
||||
newest_register["three"] = 9
|
||||
new_register.static["four"] = 5
|
||||
new_register.static["five"] = 15
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class TagUnitTest < Minitest::Test
|
||||
|
||||
assert_equal 'hello', template.render
|
||||
|
||||
buf = +''
|
||||
buf = +''
|
||||
output = template.render({}, output: buf)
|
||||
assert_equal 'hello', output
|
||||
assert_equal 'hello', buf
|
||||
@@ -51,7 +51,7 @@ class TagUnitTest < Minitest::Test
|
||||
|
||||
assert_equal 'foohellobar', template.render
|
||||
|
||||
buf = +''
|
||||
buf = +''
|
||||
output = template.render({}, output: buf)
|
||||
assert_equal 'foohellobar', output
|
||||
assert_equal 'foohellobar', buf
|
||||
|
||||
@@ -22,7 +22,7 @@ class TemplateUnitTest < Minitest::Test
|
||||
|
||||
def test_with_cache_classes_tags_returns_the_same_class
|
||||
original_cache_setting = Liquid.cache_classes
|
||||
Liquid.cache_classes = true
|
||||
Liquid.cache_classes = true
|
||||
|
||||
original_klass = Class.new
|
||||
Object.send(:const_set, :CustomTag, original_klass)
|
||||
@@ -42,7 +42,7 @@ class TemplateUnitTest < Minitest::Test
|
||||
|
||||
def test_without_cache_classes_tags_reloads_the_class
|
||||
original_cache_setting = Liquid.cache_classes
|
||||
Liquid.cache_classes = false
|
||||
Liquid.cache_classes = false
|
||||
|
||||
original_klass = Class.new
|
||||
Object.send(:const_set, :CustomTag, original_klass)
|
||||
|
||||
@@ -34,7 +34,7 @@ class TokenizerTest < Minitest::Test
|
||||
|
||||
def tokenize(source)
|
||||
tokenizer = Liquid::Tokenizer.new(source)
|
||||
tokens = []
|
||||
tokens = []
|
||||
while (t = tokenizer.shift)
|
||||
tokens << t
|
||||
end
|
||||
@@ -42,7 +42,7 @@ class TokenizerTest < Minitest::Test
|
||||
end
|
||||
|
||||
def tokenize_line_numbers(source)
|
||||
tokenizer = Liquid::Tokenizer.new(source, true)
|
||||
tokenizer = Liquid::Tokenizer.new(source, true)
|
||||
line_numbers = []
|
||||
loop do
|
||||
line_number = tokenizer.line_number
|
||||
|
||||
Reference in New Issue
Block a user