From 658ad7a6cabe0c8b6b3ae11db1a4cc8434152ec4 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 6 Dec 2023 23:22:25 +0100 Subject: [PATCH] Fix flaky tests related to file creation (#28248) --- .../post_deployment_migration_generator_spec.rb | 2 +- spec/lib/mastodon/cli/emoji_spec.rb | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/spec/generators/post_deployment_migration_generator_spec.rb b/spec/generators/post_deployment_migration_generator_spec.rb index d770a78e97..55e70a7917 100644 --- a/spec/generators/post_deployment_migration_generator_spec.rb +++ b/spec/generators/post_deployment_migration_generator_spec.rb @@ -12,7 +12,7 @@ describe PostDeploymentMigrationGenerator, type: :generator do include FileUtils tests described_class - destination File.expand_path('../../tmp', __dir__) + destination Rails.root.join('tmp', 'generator-test') before { prepare_destination } after { rm_rf(destination_root) } diff --git a/spec/lib/mastodon/cli/emoji_spec.rb b/spec/lib/mastodon/cli/emoji_spec.rb index 530da91e74..3441413b90 100644 --- a/spec/lib/mastodon/cli/emoji_spec.rb +++ b/spec/lib/mastodon/cli/emoji_spec.rb @@ -41,11 +41,17 @@ describe Mastodon::CLI::Emoji do describe '#export' do context 'with existing custom emoji' do - before { Fabricate(:custom_emoji) } - after { File.delete(export_path) } + before do + FileUtils.rm_rf(export_path.dirname) + FileUtils.mkdir_p(export_path.dirname) + + Fabricate(:custom_emoji) + end + + after { FileUtils.rm_rf(export_path.dirname) } - let(:export_path) { Rails.root.join('tmp', 'export.tar.gz') } - let(:args) { [Rails.root.join('tmp')] } + let(:export_path) { Rails.root.join('tmp', 'cli-tests', 'export.tar.gz') } + let(:args) { [export_path.dirname.to_s] } let(:action) { :export } it 'reports about exported emoji' do