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/lib/gitlab/console_spec.rb')
-rw-r--r--spec/lib/gitlab/console_spec.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/lib/gitlab/console_spec.rb b/spec/lib/gitlab/console_spec.rb
new file mode 100644
index 00000000000..f043433b4c5
--- /dev/null
+++ b/spec/lib/gitlab/console_spec.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+
+RSpec.describe Gitlab::Console do
+ describe '.welcome!' do
+ context 'when running in the Rails console' do
+ before do
+ allow(Gitlab::Runtime).to receive(:console?).and_return(true)
+ allow(Gitlab::Metrics::BootTimeTracker.instance).to receive(:startup_time).and_return(42)
+ end
+
+ shared_examples 'console messages' do
+ it 'prints system info' do
+ expect($stdout).to receive(:puts).ordered.with(include("--"))
+ expect($stdout).to receive(:puts).ordered.with(include("Ruby:"))
+ expect($stdout).to receive(:puts).ordered.with(include("GitLab:"))
+ expect($stdout).to receive(:puts).ordered.with(include("GitLab Shell:"))
+ expect($stdout).to receive(:puts).ordered.with(include("PostgreSQL:"))
+ expect($stdout).to receive(:puts).ordered.with(include("--"))
+ expect($stdout).not_to receive(:puts).ordered
+
+ described_class.welcome!
+ end
+ end
+
+ # This is to add line coverage, not to actually verify behavior on macOS.
+ context 'on darwin' do
+ before do
+ stub_const('RUBY_PLATFORM', 'x86_64-darwin-19')
+ end
+
+ it_behaves_like 'console messages'
+ end
+
+ it_behaves_like 'console messages'
+ end
+
+ context 'when not running in the Rails console' do
+ before do
+ allow(Gitlab::Runtime).to receive(:console?).and_return(false)
+ end
+
+ it 'does not print anything' do
+ expect($stdout).not_to receive(:puts)
+
+ described_class.welcome!
+ end
+ end
+ end
+end