Skip to content

Commit dccc2fb

Browse files
hsbtclaude
andcommitted
Add tests for created_at field in compact index info output
Port the rspec tests from rubygems/compact_index#183 to minitest, covering created_at presence, coexistence with other fields, and nil omission. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent eff42b2 commit dccc2fb

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

test/helpers/compact_index_helpers.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ def build_version(**args)
1111
args.fetch(:info_checksum, "info+#{name}+#{number}"),
1212
args[:dependencies],
1313
args[:ruby_version],
14-
args[:rubygems_version]
14+
args[:rubygems_version],
15+
args[:created_at]
1516
)
1617
end
1718
end

test/lib/compact_index_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,23 @@ class CompactIndexTest < ActiveSupport::TestCase
121121

122122
assert_equal "---\n1.0.1-jruby |checksum:sum+test_gem+1.0.1\n", CompactIndex.info(param)
123123
end
124+
125+
should "show created_at timestamp" do
126+
param = [build_version(number: "1.0.1", created_at: "2024-05-01T12:00:00Z")]
127+
128+
assert_equal "---\n1.0.1 |checksum:sum+test_gem+1.0.1,created_at:2024-05-01T12:00:00Z\n", CompactIndex.info(param)
129+
end
130+
131+
should "show created_at with other requirements" do
132+
param = [build_version(number: "1.0.1", ruby_version: ">1.9", created_at: "2024-05-01T12:00:00Z")]
133+
134+
assert_equal "---\n1.0.1 |checksum:sum+test_gem+1.0.1,ruby:>1.9,created_at:2024-05-01T12:00:00Z\n", CompactIndex.info(param)
135+
end
136+
137+
should "omit created_at when nil" do
138+
param = [build_version(number: "1.0.1")]
139+
140+
refute_includes CompactIndex.info(param), "created_at"
141+
end
124142
end
125143
end

0 commit comments

Comments
 (0)