Skip to content

Commit 81121ee

Browse files
committed
Fix tests that fail depending on user's local .gemrc file.
Without writing .gemrc, the gem source -a and -r don't work correctly. In particular, the presence of update_sources: true in .gemrc breaks one test, while writing the .gemrc fixes a previously skipped test.
1 parent 93a8a01 commit 81121ee

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

spec/integration_spec.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,27 @@
152152
end
153153

154154
it "finds private gems when just the private source is configured", db_transaction: false do
155-
skip "this doesn't work because Rubygems sends /specs.4.8.gz instead of /private/specs.4.8.gz"
155+
File.write(File.join(env_dir, ".gemrc"), "---\nsources:\n - #{host}\n")
156156
env = { "HOME" => env_dir }
157+
158+
# This way of adjusting sources is required for ruby 3.2 and 3.1 to pass.
157159
expect(execute("gem", ["source", "-r", "https://rubygems.org/"], env: env)).to exit_success
158160
expect(execute("gem", ["source", "-a", host], env: env)).to exit_success
161+
159162
expect(execute("gem", ["search", "-ar", "speaker"], env: env)).
160163
to exit_success.and_output(/speaker \(0.1.0\)/)
161164
end
162165

163166
it "finds private gems when just the private source is configured with a trailing slash", db_transaction: false do
167+
# The presence of `update_sources: true` in the .gemrc file breaks this test, and only this test.
168+
# Write a clean .gemrc file to avoid that. (This also makes the test much faster.)
169+
File.write(File.join(env_dir, ".gemrc"), "---\nsources:\n - #{host}/\n")
164170
env = { "HOME" => env_dir }
171+
172+
# This way of adjusting sources is required for ruby 3.2 and 3.1 to pass.
165173
expect(execute("gem", ["source", "-r", "https://rubygems.org/"], env: env)).to exit_success
166174
expect(execute("gem", ["source", "-a", "#{host}/"], env: env)).to exit_success
175+
167176
expect(execute("gem", ["search", "-ar", "speaker"], env: env)).
168177
to exit_success.and_output(/speaker \(0.1.0\)/)
169178
end

0 commit comments

Comments
 (0)