aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2019-07-27 12:37:09 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2019-07-27 12:37:09 +0900
commit6f35244defbb410373a9ffca8468ab482800ffd9 (patch)
tree2505a30ea1ada66ea853cc5c4ab498900e12ccfe /railties
parente69a7ee42dc09892477808f1243d029ce1abf311 (diff)
downloadrails-6f35244defbb410373a9ffca8468ab482800ffd9.tar.gz
rails-6f35244defbb410373a9ffca8468ab482800ffd9.tar.bz2
rails-6f35244defbb410373a9ffca8468ab482800ffd9.zip
Do not use the same temp file in different tests
It causes unexpected results when running tests in parallel. Ref: https://buildkite.com/rails/rails/builds/62610#0165f6d9-b9c8-4948-9319-07b58bfbfd4f/989-998
Diffstat (limited to 'railties')
-rw-r--r--railties/test/commands/credentials_test.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/railties/test/commands/credentials_test.rb b/railties/test/commands/credentials_test.rb
index 562e2ec382..3dec6fbe10 100644
--- a/railties/test/commands/credentials_test.rb
+++ b/railties/test/commands/credentials_test.rb
@@ -5,6 +5,7 @@ require "env_helpers"
require "rails/command"
require "rails/commands/credentials/credentials_command"
require "fileutils"
+require "tempfile"
class Rails::Command::CredentialsCommandTest < ActiveSupport::TestCase
include ActiveSupport::Testing::Isolation, EnvHelpers
@@ -110,7 +111,7 @@ class Rails::Command::CredentialsCommandTest < ActiveSupport::TestCase
end
test "edit ask the user to opt in to pretty credentials, user accepts" do
- file = File.open("foo", "w")
+ file = Tempfile.open("credentials_test")
file.write("y")
file.rewind
@@ -127,11 +128,11 @@ class Rails::Command::CredentialsCommandTest < ActiveSupport::TestCase
assert_equal("bin/rails credentials:show\n", `git config --get 'diff.rails_credentials.textconv'`)
end
ensure
- File.delete(file)
+ file.close!
end
test "edit ask the user to opt in to pretty credentials, user refuses" do
- file = File.open("foo", "w")
+ file = Tempfile.open("credentials_test")
file.write("n")
file.rewind
@@ -140,7 +141,7 @@ class Rails::Command::CredentialsCommandTest < ActiveSupport::TestCase
git_attributes = app_path(".gitattributes")
assert_not(File.exist?(git_attributes))
ensure
- File.delete(file)
+ file.close!
end
test "show credentials" do