Skip to content

Commit a60a6c0

Browse files
authored
Merge pull request #2027 from Shopify/cp-make-new-tests-serializable-to-liquid-spec
Make new tests serializable to liquid-spec
2 parents 22e979a + bad29ca commit a60a6c0

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

.github/workflows/liquid.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ jobs:
2222
rubyopt: "--enable-frozen-string-literal",
2323
}
2424
- { ruby: 3.4, allowed-failure: false, rubyopt: "--yjit" }
25-
- { ruby: ruby-head, allowed-failure: false }
25+
- { ruby: head, allowed-failure: false }
2626
- {
27-
ruby: ruby-head,
27+
ruby: head,
2828
allowed-failure: false,
2929
rubyopt: "--enable-frozen-string-literal",
3030
}
31-
- { ruby: ruby-head, allowed-failure: false, rubyopt: "--yjit" }
31+
- { ruby: head, allowed-failure: false, rubyopt: "--yjit" }
3232
name: Test Ruby ${{ matrix.entry.ruby }}
3333
steps:
3434
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
35-
- uses: ruby/setup-ruby@dffc446db9ba5a0c4446edb5bca1c5c473a806c5 # v1.235.0
35+
- uses: ruby/setup-ruby@a25f1e45f0e65a92fcb1e95e8847f78fb0a7197a # v1.273.0
3636
with:
3737
ruby-version: ${{ matrix.entry.ruby }}
3838
bundler-cache: true
@@ -46,7 +46,7 @@ jobs:
4646
runs-on: ubuntu-latest
4747
steps:
4848
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
49-
- uses: ruby/setup-ruby@dffc446db9ba5a0c4446edb5bca1c5c473a806c5 # v1.235.0
49+
- uses: ruby/setup-ruby@a25f1e45f0e65a92fcb1e95e8847f78fb0a7197a # v1.273.0
5050
with:
5151
bundler-cache: true
5252
- run: bundle exec rake memory_profile:run

test/integration/hash_rendering_test.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,11 @@ def test_render_hash_with_hash_key
8888
end
8989

9090
def test_rendering_hash_with_custom_to_s_method_uses_custom_to_s
91-
my_hash = Class.new(Hash) do
92-
def to_s
93-
"kewl"
94-
end
95-
end.new
96-
97-
assert_template_result("kewl", "{{ my_hash }}", { "my_hash" => my_hash })
91+
assert_template_result("kewl", "{{ my_hash }}", { "my_hash" => HashWithCustomToS.new })
9892
end
9993

10094
def test_rendering_hash_without_custom_to_s_uses_default_inspect
101-
my_hash = Class.new(Hash).new
95+
my_hash = HashWithoutCustomToS.new
10296
my_hash[:foo] = :bar
10397

10498
assert_template_result("{:foo=>:bar}", "{{ my_hash }}", { "my_hash" => my_hash })

test/integration/standard_filter_test.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,7 @@ def test_join
294294
end
295295

296296
def test_join_calls_to_liquid_on_each_element
297-
drop = Class.new(Liquid::Drop) do
298-
def to_liquid
299-
'i did it'
300-
end
301-
end
302-
303-
assert_equal('i did it, i did it', @filters.join([drop.new, drop.new], ", "))
297+
assert_equal('i did it, i did it', @filters.join([CustomToLiquidDrop.new('i did it'), CustomToLiquidDrop.new('i did it')], ", "))
304298
end
305299

306300
def test_sort

test/test_helper.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,26 @@ def exception
199199
end
200200
end
201201

202+
class CustomToLiquidDrop < Liquid::Drop
203+
def initialize(value)
204+
@value = value
205+
super()
206+
end
207+
208+
def to_liquid
209+
@value
210+
end
211+
end
212+
213+
class HashWithCustomToS < Hash
214+
def to_s
215+
"kewl"
216+
end
217+
end
218+
219+
class HashWithoutCustomToS < Hash
220+
end
221+
202222
class StubFileSystem
203223
attr_reader :file_read_count
204224

0 commit comments

Comments
 (0)