mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Apply simple rubocop fixes
This commit is contained in:
@@ -68,7 +68,7 @@ class ConditionUnitTest < Minitest::Test
|
||||
assert_nil Condition.new({}, '>', 2).evaluate
|
||||
assert_nil Condition.new(2, '>', {}).evaluate
|
||||
assert_equal false, Condition.new({}, '==', 2).evaluate
|
||||
assert_equal true, Condition.new({ 'a' => 1 }, '==', { 'a' => 1 }).evaluate
|
||||
assert_equal true, Condition.new({ 'a' => 1 }, '==', 'a' => 1).evaluate
|
||||
assert_equal true, Condition.new({ 'a' => 2 }, 'contains', 'a').evaluate
|
||||
end
|
||||
|
||||
@@ -107,11 +107,11 @@ class ConditionUnitTest < Minitest::Test
|
||||
|
||||
assert_equal false, condition.evaluate
|
||||
|
||||
condition.or Condition.new(2, '==', 1)
|
||||
condition.or(Condition.new(2, '==', 1))
|
||||
|
||||
assert_equal false, condition.evaluate
|
||||
|
||||
condition.or Condition.new(1, '==', 1)
|
||||
condition.or(Condition.new(1, '==', 1))
|
||||
|
||||
assert_equal true, condition.evaluate
|
||||
end
|
||||
@@ -121,22 +121,22 @@ class ConditionUnitTest < Minitest::Test
|
||||
|
||||
assert_equal true, condition.evaluate
|
||||
|
||||
condition.and Condition.new(2, '==', 2)
|
||||
condition.and(Condition.new(2, '==', 2))
|
||||
|
||||
assert_equal true, condition.evaluate
|
||||
|
||||
condition.and Condition.new(2, '==', 1)
|
||||
condition.and(Condition.new(2, '==', 1))
|
||||
|
||||
assert_equal false, condition.evaluate
|
||||
end
|
||||
|
||||
def test_should_allow_custom_proc_operator
|
||||
Condition.operators['starts_with'] = proc { |cond, left, right| left =~ %r{^#{right}} }
|
||||
Condition.operators['starts_with'] = proc { |_cond, left, right| left =~ /^#{right}/ }
|
||||
|
||||
assert_evaluates_true 'bob', 'starts_with', 'b'
|
||||
assert_evaluates_false 'bob', 'starts_with', 'o'
|
||||
ensure
|
||||
Condition.operators.delete 'starts_with'
|
||||
Condition.operators.delete('starts_with')
|
||||
end
|
||||
|
||||
def test_left_or_right_may_contain_operators
|
||||
|
||||
@@ -206,9 +206,9 @@ class ContextUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_merge
|
||||
@context.merge({ "test" => "test" })
|
||||
@context.merge("test" => "test")
|
||||
assert_equal 'test', @context['test']
|
||||
@context.merge({ "test" => "newvalue", "foo" => "bar" })
|
||||
@context.merge("test" => "newvalue", "foo" => "bar")
|
||||
assert_equal 'newvalue', @context['test']
|
||||
assert_equal 'bar', @context['foo']
|
||||
end
|
||||
@@ -235,10 +235,10 @@ class ContextUnitTest < Minitest::Test
|
||||
|
||||
def test_hash_to_array_transition
|
||||
@context['colors'] = {
|
||||
'Blue' => ['003366', '336699', '6699CC', '99CCFF'],
|
||||
'Green' => ['003300', '336633', '669966', '99CC99'],
|
||||
'Yellow' => ['CC9900', 'FFCC00', 'FFFF99', 'FFFFCC'],
|
||||
'Red' => ['660000', '993333', 'CC6666', 'FF9999']
|
||||
'Blue' => ['003366', '336699', '6699CC', '99CCFF'],
|
||||
'Green' => ['003300', '336633', '669966', '99CC99'],
|
||||
'Yellow' => ['CC9900', 'FFCC00', 'FFFF99', 'FFFFCC'],
|
||||
'Red' => ['660000', '993333', 'CC6666', 'FF9999'],
|
||||
}
|
||||
|
||||
assert_equal '003366', @context['colors.Blue[0]']
|
||||
@@ -263,7 +263,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]']
|
||||
@@ -301,7 +301,7 @@ class ContextUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_first_can_appear_in_middle_of_callchain
|
||||
@context['product'] = { 'variants' => [ { 'title' => 'draft151cm' }, { 'title' => 'element151cm' } ] }
|
||||
@context['product'] = { 'variants' => [{ 'title' => 'draft151cm' }, { 'title' => 'element151cm' }] }
|
||||
|
||||
assert_equal 'draft151cm', @context['product.variants[0].title']
|
||||
assert_equal 'element151cm', @context['product.variants[1].title']
|
||||
@@ -453,7 +453,7 @@ 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']
|
||||
@@ -514,7 +514,7 @@ class ContextUnitTest < Minitest::Test
|
||||
|
||||
def test_new_isolated_subcontext_does_not_inherit_non_static_registers
|
||||
registers = {
|
||||
my_register: :my_value
|
||||
my_register: :my_value,
|
||||
}
|
||||
super_context = Context.new({}, {}, registers)
|
||||
subcontext = super_context.new_isolated_subcontext
|
||||
|
||||
@@ -4,7 +4,7 @@ class PartialCacheUnitTest < Minitest::Test
|
||||
def test_uses_the_file_system_register_if_present
|
||||
context = Liquid::Context.build(
|
||||
registers: {
|
||||
file_system: StubFileSystem.new('my_partial' => 'my partial body')
|
||||
file_system: StubFileSystem.new('my_partial' => 'my partial body'),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -41,12 +41,12 @@ class PartialCacheUnitTest < Minitest::Test
|
||||
)
|
||||
context_one = Liquid::Context.build(
|
||||
registers: {
|
||||
file_system: shared_file_system
|
||||
file_system: shared_file_system,
|
||||
}
|
||||
)
|
||||
context_two = Liquid::Context.build(
|
||||
registers: {
|
||||
file_system: shared_file_system
|
||||
file_system: shared_file_system,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ class StrainerUnitTest < Minitest::Test
|
||||
rescue Liquid::ArgumentError => e
|
||||
assert_match(
|
||||
/\ALiquid error: wrong number of arguments \((1 for 0|given 1, expected 0)\)\z/,
|
||||
e.message)
|
||||
e.message
|
||||
)
|
||||
assert_equal e.backtrace[0].split(':')[0], __FILE__
|
||||
end
|
||||
end
|
||||
@@ -135,7 +136,7 @@ class StrainerUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
module LateAddedFilter
|
||||
def late_added_filter(input)
|
||||
def late_added_filter(_input)
|
||||
"filtered"
|
||||
end
|
||||
end
|
||||
@@ -150,7 +151,7 @@ class StrainerUnitTest < Minitest::Test
|
||||
mod = Module.new do
|
||||
class << self
|
||||
attr_accessor :include_count
|
||||
def included(mod)
|
||||
def included(_mod)
|
||||
self.include_count += 1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,6 +3,6 @@ require 'test_helper'
|
||||
class IfTagUnitTest < Minitest::Test
|
||||
def test_if_nodelist
|
||||
template = Liquid::Template.parse('{% if true %}IF{% else %}ELSE{% endif %}')
|
||||
assert_equal ['IF', 'ELSE'], template.root.nodelist[0].nodelist.map(&:nodelist).flatten
|
||||
assert_equal(['IF', 'ELSE'], template.root.nodelist[0].nodelist.map(&:nodelist).flatten)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user