Skip to content

Commit 8baf4d4

Browse files
committed
Document and test all available gemrc configuration keys
Document missing gemrc configuration keys. The documented configuration key order aligns with the following part. https://github.com/ruby/rubygems/blob/287175d4ae57340e22c6f1d21da1489d7dac35c5/lib/rubygems/config_file.rb#L240-L257 Add and update tests for missing gemrc configuration use_psych and gemhome key assertions. Fix test_initialize_global_gem_cache_gemrc and test_initialize_concurrent_downloads to test with symbolic keys, as global_gem_cache and use_psych keys are documented as a symbolic key.
1 parent 287175d commit 8baf4d4

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

lib/rubygems/config_file.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,22 @@
2626
# RubyGems options use symbol keys. Valid options are:
2727
#
2828
# +:backtrace+:: See #backtrace
29-
# +:sources+:: Sets Gem::sources
29+
# +:bulk_threshold+:: See #bulk_threshold
3030
# +:verbose+:: See #verbose
31+
# +:update_sources+:: See #update_sources
3132
# +:concurrent_downloads+:: See #concurrent_downloads
33+
# +:cert_expiration_length_days+:: See #cert_expiration_length_days
34+
# +:install_extension_in_lib+:: See #install_extension_in_lib
35+
# +:ipv4_fallback_enabled+:: See #ipv4_fallback_enabled
36+
# +:global_gem_cache+:: See #global_gem_cache
37+
# +:use_psych+:: See #use_psych
38+
# +:gemhome+:: See #home
39+
# +:gempath+:: See #path
40+
# +:sources+:: Sets Gem::sources
41+
# +:disable_default_gem_server+:: See #disable_default_gem_server
42+
# +:ssl_verify_mode+:: See #ssl_verify_mode
43+
# +:ssl_ca_cert+:: See #ssl_ca_cert
44+
# +:ssl_client_cert+:: See #ssl_client_cert
3245
#
3346
# gemrc files may exist in various locations and are read and merged in
3447
# the following order:

test/rubygems/test_gem_config_file.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def test_initialize
5353
fp.puts ":sources:"
5454
fp.puts " - http://more-gems.example.com"
5555
fp.puts "install: --wrappers"
56+
fp.puts ":gemhome: /tmp/gems"
5657
fp.puts ":gempath:"
5758
fp.puts "- /usr/ruby/1.8/lib/ruby/gems/1.8"
5859
fp.puts "- /var/ruby/1.8/gem_home"
@@ -61,6 +62,7 @@ def test_initialize
6162
fp.puts ":cert_expiration_length_days: 28"
6263
fp.puts ":install_extension_in_lib: false"
6364
fp.puts ":ipv4_fallback_enabled: true"
65+
fp.puts ":use_psych: true"
6466
end
6567

6668
util_config_file
@@ -70,13 +72,15 @@ def test_initialize
7072
assert_equal false, @cfg.update_sources
7173
assert_equal %w[http://more-gems.example.com], @cfg.sources
7274
assert_equal "--wrappers", @cfg[:install]
75+
assert_equal "/tmp/gems", @cfg.home
7376
assert_equal(["/usr/ruby/1.8/lib/ruby/gems/1.8", "/var/ruby/1.8/gem_home"],
7477
@cfg.path)
7578
assert_equal 0, @cfg.ssl_verify_mode
7679
assert_equal "/etc/ssl/certs", @cfg.ssl_ca_cert
7780
assert_equal 28, @cfg.cert_expiration_length_days
7881
assert_equal false, @cfg.install_extension_in_lib
7982
assert_equal true, @cfg.ipv4_fallback_enabled
83+
assert_equal true, @cfg.use_psych
8084
end
8185

8286
def test_initialize_ipv4_fallback_enabled_env
@@ -105,17 +109,27 @@ def test_initialize_global_gem_cache_env
105109

106110
def test_initialize_global_gem_cache_gemrc
107111
File.open @temp_conf, "w" do |fp|
108-
fp.puts "global_gem_cache: true"
112+
fp.puts ":global_gem_cache: true"
109113
end
110114

111115
util_config_file %W[--config-file #{@temp_conf}]
112116

113117
assert_equal true, @cfg.global_gem_cache
114118
end
115119

120+
def test_initialize_use_psych_env
121+
orig_use_psych = ENV["RUBYGEMS_USE_PSYCH"]
122+
ENV["RUBYGEMS_USE_PSYCH"] = "true"
123+
util_config_file %W[--config-file #{@temp_conf}]
124+
125+
assert_equal true, @cfg.use_psych
126+
ensure
127+
ENV["RUBYGEMS_USE_PSYCH"] = orig_use_psych
128+
end
129+
116130
def test_initialize_concurrent_downloads
117131
File.open @temp_conf, "w" do |fp|
118-
fp.puts "concurrent_downloads: 2"
132+
fp.puts ":concurrent_downloads: 2"
119133
end
120134

121135
util_config_file %W[--config-file #{@temp_conf}]

0 commit comments

Comments
 (0)