mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 03:10:39 -07:00
Merge pull request #2027 from Shopify/cp-make-new-tests-serializable-to-liquid-spec
Make new tests serializable to liquid-spec
This commit is contained in:
@@ -22,17 +22,17 @@ jobs:
|
|||||||
rubyopt: "--enable-frozen-string-literal",
|
rubyopt: "--enable-frozen-string-literal",
|
||||||
}
|
}
|
||||||
- { ruby: 3.4, allowed-failure: false, rubyopt: "--yjit" }
|
- { ruby: 3.4, allowed-failure: false, rubyopt: "--yjit" }
|
||||||
- { ruby: ruby-head, allowed-failure: false }
|
- { ruby: head, allowed-failure: false }
|
||||||
- {
|
- {
|
||||||
ruby: ruby-head,
|
ruby: head,
|
||||||
allowed-failure: false,
|
allowed-failure: false,
|
||||||
rubyopt: "--enable-frozen-string-literal",
|
rubyopt: "--enable-frozen-string-literal",
|
||||||
}
|
}
|
||||||
- { ruby: ruby-head, allowed-failure: false, rubyopt: "--yjit" }
|
- { ruby: head, allowed-failure: false, rubyopt: "--yjit" }
|
||||||
name: Test Ruby ${{ matrix.entry.ruby }}
|
name: Test Ruby ${{ matrix.entry.ruby }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||||
- uses: ruby/setup-ruby@dffc446db9ba5a0c4446edb5bca1c5c473a806c5 # v1.235.0
|
- uses: ruby/setup-ruby@a25f1e45f0e65a92fcb1e95e8847f78fb0a7197a # v1.273.0
|
||||||
with:
|
with:
|
||||||
ruby-version: ${{ matrix.entry.ruby }}
|
ruby-version: ${{ matrix.entry.ruby }}
|
||||||
bundler-cache: true
|
bundler-cache: true
|
||||||
@@ -46,7 +46,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||||
- uses: ruby/setup-ruby@dffc446db9ba5a0c4446edb5bca1c5c473a806c5 # v1.235.0
|
- uses: ruby/setup-ruby@a25f1e45f0e65a92fcb1e95e8847f78fb0a7197a # v1.273.0
|
||||||
with:
|
with:
|
||||||
bundler-cache: true
|
bundler-cache: true
|
||||||
- run: bundle exec rake memory_profile:run
|
- run: bundle exec rake memory_profile:run
|
||||||
|
|||||||
@@ -88,17 +88,11 @@ class HashRenderingTest < Minitest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_rendering_hash_with_custom_to_s_method_uses_custom_to_s
|
def test_rendering_hash_with_custom_to_s_method_uses_custom_to_s
|
||||||
my_hash = Class.new(Hash) do
|
assert_template_result("kewl", "{{ my_hash }}", { "my_hash" => HashWithCustomToS.new })
|
||||||
def to_s
|
|
||||||
"kewl"
|
|
||||||
end
|
|
||||||
end.new
|
|
||||||
|
|
||||||
assert_template_result("kewl", "{{ my_hash }}", { "my_hash" => my_hash })
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rendering_hash_without_custom_to_s_uses_default_inspect
|
def test_rendering_hash_without_custom_to_s_uses_default_inspect
|
||||||
my_hash = Class.new(Hash).new
|
my_hash = HashWithoutCustomToS.new
|
||||||
my_hash[:foo] = :bar
|
my_hash[:foo] = :bar
|
||||||
|
|
||||||
assert_template_result("{:foo=>:bar}", "{{ my_hash }}", { "my_hash" => my_hash })
|
assert_template_result("{:foo=>:bar}", "{{ my_hash }}", { "my_hash" => my_hash })
|
||||||
|
|||||||
@@ -294,13 +294,7 @@ class StandardFiltersTest < Minitest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_join_calls_to_liquid_on_each_element
|
def test_join_calls_to_liquid_on_each_element
|
||||||
drop = Class.new(Liquid::Drop) do
|
assert_equal('i did it, i did it', @filters.join([CustomToLiquidDrop.new('i did it'), CustomToLiquidDrop.new('i did it')], ", "))
|
||||||
def to_liquid
|
|
||||||
'i did it'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_equal('i did it, i did it', @filters.join([drop.new, drop.new], ", "))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sort
|
def test_sort
|
||||||
|
|||||||
@@ -199,6 +199,26 @@ class ErrorDrop < Liquid::Drop
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class CustomToLiquidDrop < Liquid::Drop
|
||||||
|
def initialize(value)
|
||||||
|
@value = value
|
||||||
|
super()
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_liquid
|
||||||
|
@value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class HashWithCustomToS < Hash
|
||||||
|
def to_s
|
||||||
|
"kewl"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class HashWithoutCustomToS < Hash
|
||||||
|
end
|
||||||
|
|
||||||
class StubFileSystem
|
class StubFileSystem
|
||||||
attr_reader :file_read_count
|
attr_reader :file_read_count
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user