Skip to content

Commit e24041c

Browse files
hsbtclaude
andcommitted
Port Bundler's YAML serializer specs to the RubyGems test suite
The RubyGems test suite already covers almost all of the Bundler yaml_serializer spec through test_gem_safe_yaml.rb. Port the two missing cases (URL mapping keys as used by mirror settings, and Psych interoperability in both directions) and drop the Bundler spec. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 60b7f81 commit e24041c

3 files changed

Lines changed: 39 additions & 236 deletions

File tree

spec/bundler/yaml_serializer_spec.rb

Lines changed: 0 additions & 235 deletions
This file was deleted.

spec/support/shards.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ module Shards
4242
"spec/bundler/env_spec.rb",
4343
"spec/install/gems/mirror_spec.rb",
4444
"spec/install/failure_spec.rb",
45-
"spec/bundler/yaml_serializer_spec.rb",
4645
"spec/bundler/environment_preserver_spec.rb",
4746
"spec/install/gemfile/install_if_spec.rb",
4847
"spec/install/gems/gemfile_source_header_spec.rb",

test/rubygems/test_gem_safe_yaml.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,45 @@ def test_roundtrip_empty_collections
950950
assert_equal({}, loaded["hash"])
951951
end
952952

953+
def test_load_url_key_and_value
954+
# Bundler mirror settings use URLs both as mapping key and value
955+
yaml = "BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG/: http://example-mirror.rubygems.org\n"
956+
957+
expected = { "BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG/" => "http://example-mirror.rubygems.org" }
958+
assert_equal expected, yaml_load(yaml)
959+
end
960+
961+
def test_psych_interop_roundtrip
962+
require "yaml"
963+
964+
hash = {
965+
"a_joke" => {
966+
"my-stand" => "I can totally keep secrets",
967+
"but" => "The people I tell them to can't :P",
968+
"wouldn't it be funny if this string were empty?" => "",
969+
},
970+
"more" => {
971+
"first" => [
972+
"Can a kangaroo jump higher than a house?",
973+
"Of course, a house doesn't jump at all.",
974+
],
975+
"second" => [
976+
"What did the sea say to the sand?",
977+
"Nothing, it simply waved.",
978+
],
979+
"array with empty string" => [""],
980+
},
981+
"sales" => {
982+
"item" => "A Parachute",
983+
"description" => "Only used once, never opened.",
984+
},
985+
"one-more" => "I'd tell you a chemistry joke but I know I wouldn't get a reaction.",
986+
}
987+
988+
assert_equal hash, Gem::YAMLSerializer.load(Psych.dump(hash))
989+
assert_equal hash, Psych.load(Gem::YAMLSerializer.dump(hash))
990+
end
991+
953992
def test_load_double_quoted_escape_sequences
954993
result = yaml_load("newline: \"hello\\nworld\"")
955994
assert_equal "hello\nworld", result["newline"]

0 commit comments

Comments
 (0)