WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 546ee9d

Browse files
Copilotbenbalter
andcommitted
Add tests for Time object handling in Value#to_liquid
Co-authored-by: benbalter <[email protected]>
1 parent 4138e1b commit 546ee9d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spec/value_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
let(:nil_value_without_key) { described_class.new(nil) }
1212
let(:nil_value_with_key) { described_class.new("my_key", nil) }
1313
let(:key_and_value) { described_class.new("my_key2", proc { "leonard told me" }) }
14+
let(:time_value) { described_class.new(Time.utc(2025, 1, 29, 12, 0, 0)) }
1415

1516
it "takes in a value and stores it" do
1617
v = described_class.new("some_value")
@@ -55,6 +56,16 @@
5556
expect(hash_value.render).to eql("hello" => "world")
5657
end
5758

59+
it "does not modify a time value" do
60+
expect(time_value.render).to be_a(Time)
61+
expect(time_value.render).to eql(Time.utc(2025, 1, 29, 12, 0, 0))
62+
end
63+
64+
it "returns Time objects directly from to_liquid for date filter compatibility" do
65+
expect(time_value.to_liquid).to be_a(Time)
66+
expect(time_value.to_liquid).to eql(Time.utc(2025, 1, 29, 12, 0, 0))
67+
end
68+
5869
it "accepts a nil value with no key" do
5970
expect(nil_value_without_key.key).to eql("{anonymous}")
6071
expect(nil_value_without_key.render).to be_nil

0 commit comments

Comments
 (0)