summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rdoc/test_rdoc_ri_driver.rb22
-rw-r--r--test/rdoc/test_rdoc_store.rb7
-rw-r--r--test/rubygems/test_gem.rb2
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_cert_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_signout_command.rb1
-rw-r--r--test/rubygems/test_gem_config_file.rb4
-rw-r--r--test/rubygems/test_gem_source.rb2
-rw-r--r--test/rubygems/test_gem_spec_fetcher.rb2
9 files changed, 25 insertions, 21 deletions
diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb
index 6f17fecec91..1a8ac3dde53 100644
--- a/test/rdoc/test_rdoc_ri_driver.rb
+++ b/test/rdoc/test_rdoc_ri_driver.rb
@@ -15,6 +15,8 @@ class TestRDocRIDriver < RDoc::TestCase
@orig_ri = ENV['RI']
@orig_home = ENV['HOME']
ENV['HOME'] = @tmpdir
+ @rdoc_home = File.join ENV["HOME"], ".rdoc"
+ FileUtils.mkdir_p @rdoc_home
ENV.delete 'RI'
@options = RDoc::RI::Driver.default_options
@@ -81,7 +83,7 @@ class TestRDocRIDriver < RDoc::TestCase
@RM::Rule.new(1),
@RM::Paragraph.new('Also found in:'),
@RM::Verbatim.new("ruby core", "\n",
- "~/.rdoc", "\n"))
+ @rdoc_home, "\n"))
assert_equal expected, out
end
@@ -231,7 +233,7 @@ class TestRDocRIDriver < RDoc::TestCase
doc(
head(1, 'Foo::Bar#blah'),
blank_line,
- para('(from ~/.rdoc)'),
+ para("(from #{@rdoc_home})"),
head(3, 'Implementation from Bar'),
rule(1),
verb("blah(5) => 5\n",
@@ -254,7 +256,7 @@ class TestRDocRIDriver < RDoc::TestCase
doc(
head(1, 'Qux#aliased'),
blank_line,
- para('(from ~/.rdoc)'),
+ para("(from #{@rdoc_home})"),
rule(1),
blank_line,
para('alias comment'),
@@ -280,7 +282,7 @@ class TestRDocRIDriver < RDoc::TestCase
doc(
head(1, 'Foo::Bar#attr'),
blank_line,
- para('(from ~/.rdoc)'),
+ para("(from #{@rdoc_home})"),
rule(1),
blank_line,
blank_line)
@@ -299,7 +301,7 @@ class TestRDocRIDriver < RDoc::TestCase
doc(
head(1, 'Bar#inherit'),
blank_line,
- para('(from ~/.rdoc)'),
+ para("(from #{@rdoc_home})"),
head(3, 'Implementation from Foo'),
rule(1),
blank_line,
@@ -343,13 +345,13 @@ class TestRDocRIDriver < RDoc::TestCase
doc(
head(1, 'Foo#inherit'),
blank_line,
- para('(from ~/.rdoc)'),
+ para("(from #{@rdoc_home})"),
rule(1),
blank_line,
blank_line,
head(1, 'Foo#override'),
blank_line,
- para('(from ~/.rdoc)'),
+ para("(from #{@rdoc_home})"),
rule(1),
blank_line,
para('must not be displayed in Bar#override'),
@@ -802,7 +804,7 @@ Foo::Bar#bother
@driver.display_page 'home:README'
end
- assert_match %r%= README pages in ~/\.rdoc%, out
+ assert_match %r%= README pages in #{@rdoc_home}%, out
assert_match %r%README\.rdoc%, out
assert_match %r%README\.md%, out
end
@@ -856,7 +858,7 @@ Foo::Bar#bother
@driver.display_page_list @store1
end
- assert_match %r%= Pages in ~/\.rdoc%, out
+ assert_match %r%= Pages in #{@rdoc_home}%, out
assert_match %r%README\.rdoc%, out
end
@@ -876,7 +878,7 @@ Foo::Bar#bother
@driver.display_page_list @store1
end
- assert_match %r%= Pages in ~/\.rdoc%, out
+ assert_match %r%= Pages in #{@rdoc_home}%, out
assert_match %r%README\.rdoc%, out
assert_match %r%OTHER\.rdoc%, out
end
diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb
index 8332d9233ed..076b8e7d4e4 100644
--- a/test/rdoc/test_rdoc_store.rb
+++ b/test/rdoc/test_rdoc_store.rb
@@ -317,6 +317,9 @@ class TestRDocStore < XrefTestCase
end
def test_friendly_path
+ @orig_xdg_data_home = ENV['XDG_DATA_HOME']
+ ENV.delete('XDG_DATA_HOME')
+
@s.path = @tmpdir
@s.type = nil
assert_equal @s.path, @s.friendly_path
@@ -331,11 +334,13 @@ class TestRDocStore < XrefTestCase
assert_equal "ruby site", @s.friendly_path
@s.type = :home
- assert_equal "~/.rdoc", @s.friendly_path
+ assert_equal File.expand_path("~/.local/share/rdoc"), @s.friendly_path
@s.type = :gem
@s.path = "#{@tmpdir}/gem_repository/doc/gem_name-1.0/ri"
assert_equal "gem gem_name-1.0", @s.friendly_path
+ ensure
+ ENV['XDG_DATA_HOME'] = @orig_xdg_data_home
end
def test_dry_run
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index 1f5e0e6768d..5f70a2ac6b1 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -1359,6 +1359,8 @@ class TestGem < Gem::TestCase
parts = [@userhome, '.gem', Gem.ruby_engine]
parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty?
+ FileUtils.mkdir_p File.join(parts)
+
assert_equal File.join(parts), Gem.user_dir
end
diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb
index a2e8f284eb2..ca9f8b66c9f 100644
--- a/test/rubygems/test_gem_commands_build_command.rb
+++ b/test/rubygems/test_gem_commands_build_command.rb
@@ -376,7 +376,6 @@ class TestGemCommandsBuildCommand < Gem::TestCase
skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform?
gem_path = File.join Gem.user_home, ".gem"
- Dir.mkdir gem_path
Gem::Security.trust_dir
@@ -420,7 +419,6 @@ class TestGemCommandsBuildCommand < Gem::TestCase
skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform?
gem_path = File.join Gem.user_home, ".gem"
- Dir.mkdir gem_path
Gem::Security.trust_dir
diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb
index fd1e66b915d..bb9ed9e630b 100644
--- a/test/rubygems/test_gem_commands_cert_command.rb
+++ b/test/rubygems/test_gem_commands_cert_command.rb
@@ -597,7 +597,6 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
def test_execute_re_sign
gem_path = File.join Gem.user_home, ".gem"
- Dir.mkdir gem_path
path = File.join @tempdir, 'cert.pem'
Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600
@@ -628,9 +627,6 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
end
def test_execute_re_sign_with_cert_expiration_length_days
- gem_path = File.join Gem.user_home, ".gem"
- Dir.mkdir gem_path
-
path = File.join @tempdir, 'cert.pem'
Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600
diff --git a/test/rubygems/test_gem_commands_signout_command.rb b/test/rubygems/test_gem_commands_signout_command.rb
index 814b55cf4f2..9a47dafe7cd 100644
--- a/test/rubygems/test_gem_commands_signout_command.rb
+++ b/test/rubygems/test_gem_commands_signout_command.rb
@@ -8,6 +8,7 @@ class TestGemCommandsSignoutCommand < Gem::TestCase
def setup
super
+ File.delete Gem.configuration.credentials_path if File.exist?(Gem.configuration.credentials_path)
@cmd = Gem::Commands::SignoutCommand.new
end
diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb
index 260a94953e3..d31d55eba12 100644
--- a/test/rubygems/test_gem_config_file.rb
+++ b/test/rubygems/test_gem_config_file.rb
@@ -170,7 +170,7 @@ class TestGemConfigFile < Gem::TestCase
assert_nil @cfg.instance_variable_get :@api_keys
temp_cred = File.join Gem.user_home, '.gem', 'credentials'
- FileUtils.mkdir File.dirname(temp_cred)
+ FileUtils.mkdir_p File.dirname(temp_cred)
File.open temp_cred, 'w', 0600 do |fp|
fp.puts ':rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97'
end
@@ -296,7 +296,7 @@ if you believe they were disclosed to a third party.
def test_load_api_keys
temp_cred = File.join Gem.user_home, '.gem', 'credentials'
- FileUtils.mkdir File.dirname(temp_cred)
+ FileUtils.mkdir_p File.dirname(temp_cred)
File.open temp_cred, 'w', 0600 do |fp|
fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
fp.puts ":other: a5fdbb6ba150cbb83aad2bb2fede64c"
diff --git a/test/rubygems/test_gem_source.rb b/test/rubygems/test_gem_source.rb
index 05e443c7f1b..24b8edb055e 100644
--- a/test/rubygems/test_gem_source.rb
+++ b/test/rubygems/test_gem_source.rb
@@ -230,7 +230,7 @@ class TestGemSource < Gem::TestCase
end
def test_update_cache_eh_home_nonexistent
- FileUtils.rmdir Gem.user_home
+ FileUtils.rm_rf Gem.user_home
refute @source.update_cache?
end
diff --git a/test/rubygems/test_gem_spec_fetcher.rb b/test/rubygems/test_gem_spec_fetcher.rb
index b7547112bbd..d1633c4e3cc 100644
--- a/test/rubygems/test_gem_spec_fetcher.rb
+++ b/test/rubygems/test_gem_spec_fetcher.rb
@@ -33,7 +33,7 @@ class TestGemSpecFetcher < Gem::TestCase
end
def test_initialize_nonexistent_home_dir
- FileUtils.rmdir Gem.user_home
+ FileUtils.rm_rf Gem.user_home
assert Gem::SpecFetcher.new
end