Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/tasks/gitlab/db_rake_spec.rb')
-rw-r--r--spec/tasks/gitlab/db_rake_spec.rb18
1 files changed, 8 insertions, 10 deletions
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb
index c4623061944..08ca6c32b49 100644
--- a/spec/tasks/gitlab/db_rake_spec.rb
+++ b/spec/tasks/gitlab/db_rake_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
require 'rake'
-RSpec.describe 'gitlab:db namespace rake task' do
+RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
before :all do
Rake.application.rake_require 'active_record/railties/databases'
Rake.application.rake_require 'tasks/seed_fu'
@@ -306,7 +306,7 @@ RSpec.describe 'gitlab:db namespace rake task' do
let(:all_migrations) { [double('migration1', version: 1), pending_migration] }
let(:pending_migration) { double('migration2', version: 2) }
let(:filename) { Gitlab::Database::Migrations::Instrumentation::STATS_FILENAME }
- let!(:directory) { Dir.mktmpdir }
+ let(:result_dir) { Dir.mktmpdir }
let(:observations) { %w[some data] }
before do
@@ -316,19 +316,17 @@ RSpec.describe 'gitlab:db namespace rake task' do
allow(instrumentation).to receive(:observe).and_yield
- allow(Dir).to receive(:mkdir)
- allow(File).to receive(:exist?).with(directory).and_return(false)
- stub_const('Gitlab::Database::Migrations::Instrumentation::RESULT_DIR', directory)
+ stub_const('Gitlab::Database::Migrations::Instrumentation::RESULT_DIR', result_dir)
end
after do
- FileUtils.rm_rf([directory])
+ FileUtils.rm_rf(result_dir)
end
- it 'fails when the directory already exists' do
- expect(File).to receive(:exist?).with(directory).and_return(true)
+ it 'creates result directory when one does not exist' do
+ FileUtils.rm_rf(result_dir)
- expect { subject }.to raise_error(/Directory exists/)
+ expect { subject }.to change { Dir.exist?(result_dir) }.from(false).to(true)
end
it 'instruments the pending migration' do
@@ -346,7 +344,7 @@ RSpec.describe 'gitlab:db namespace rake task' do
it 'writes observations out to JSON file' do
subject
- expect(File.read(File.join(directory, filename))).to eq(observations.to_json)
+ expect(File.read(File.join(result_dir, filename))).to eq(observations.to_json)
end
end