summaryrefslogtreecommitdiff
path: root/spec/bin
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
commit85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch)
tree9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/bin
parent15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff)
downloadgitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/bin')
-rw-r--r--spec/bin/feature_flag_spec.rb40
1 files changed, 18 insertions, 22 deletions
diff --git a/spec/bin/feature_flag_spec.rb b/spec/bin/feature_flag_spec.rb
index f85b8f22210..41117880f95 100644
--- a/spec/bin/feature_flag_spec.rb
+++ b/spec/bin/feature_flag_spec.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
-require 'spec_helper'
+require 'fast_spec_helper'
+require 'rspec-parameterized'
load File.expand_path('../../bin/feature-flag', __dir__)
@@ -11,25 +12,20 @@ RSpec.describe 'bin/feature-flag' do
let(:argv) { %w[feature-flag-name -t development -g group::memory -i https://url -m http://url] }
let(:options) { FeatureFlagOptionParser.parse(argv) }
let(:creator) { described_class.new(options) }
- let(:existing_flag) { File.join('config', 'feature_flags', 'development', 'existing-feature-flag.yml') }
+ let(:existing_flags) do
+ { 'existing-feature-flag' => File.join('config', 'feature_flags', 'development', 'existing-feature-flag.yml') }
+ end
before do
- # create a dummy feature flag
- FileUtils.mkdir_p(File.dirname(existing_flag))
- File.write(existing_flag, '{}')
+ allow(creator).to receive(:all_feature_flag_names) { existing_flags }
+ allow(creator).to receive(:branch_name) { 'feature-branch' }
+ allow(creator).to receive(:editor) { nil }
# ignore writes
allow(File).to receive(:write).and_return(true)
# ignore stdin
allow($stdin).to receive(:gets).and_raise('EOF')
-
- # ignore Git commands
- allow(creator).to receive(:branch_name) { 'feature-branch' }
- end
-
- after do
- FileUtils.rm_f(existing_flag)
end
subject { creator.execute }
@@ -139,7 +135,7 @@ RSpec.describe 'bin/feature-flag' do
expect($stdin).to receive(:gets).and_return(type)
expect do
expect(described_class.read_type).to eq(:development)
- end.to output(/specify the type/).to_stdout
+ end.to output(/Specify the feature flag type/).to_stdout
end
context 'when invalid type is given' do
@@ -151,7 +147,7 @@ RSpec.describe 'bin/feature-flag' do
expect do
expect { described_class.read_type }.to raise_error(/EOF/)
- end.to output(/specify the type/).to_stdout
+ end.to output(/Specify the feature flag type/).to_stdout
.and output(/Invalid type specified/).to_stderr
end
end
@@ -165,7 +161,7 @@ RSpec.describe 'bin/feature-flag' do
expect($stdin).to receive(:gets).and_return(group)
expect do
expect(described_class.read_group).to eq('group::memory')
- end.to output(/specify the group/).to_stdout
+ end.to output(/Specify the group introducing the feature flag/).to_stdout
end
context 'invalid group given' do
@@ -177,8 +173,8 @@ RSpec.describe 'bin/feature-flag' do
expect do
expect { described_class.read_group }.to raise_error(/EOF/)
- end.to output(/specify the group/).to_stdout
- .and output(/Group needs to include/).to_stderr
+ end.to output(/Specify the group introducing the feature flag/).to_stdout
+ .and output(/The group needs to include/).to_stderr
end
end
end
@@ -190,7 +186,7 @@ RSpec.describe 'bin/feature-flag' do
expect($stdin).to receive(:gets).and_return(url)
expect do
expect(described_class.read_introduced_by_url).to eq('https://merge-request')
- end.to output(/can you paste the URL here/).to_stdout
+ end.to output(/URL of the MR introducing the feature flag/).to_stdout
end
context 'empty URL given' do
@@ -200,7 +196,7 @@ RSpec.describe 'bin/feature-flag' do
expect($stdin).to receive(:gets).and_return(url)
expect do
expect(described_class.read_introduced_by_url).to be_nil
- end.to output(/can you paste the URL here/).to_stdout
+ end.to output(/URL of the MR introducing the feature flag/).to_stdout
end
end
@@ -213,7 +209,7 @@ RSpec.describe 'bin/feature-flag' do
expect do
expect { described_class.read_introduced_by_url }.to raise_error(/EOF/)
- end.to output(/can you paste the URL here/).to_stdout
+ end.to output(/URL of the MR introducing the feature flag/).to_stdout
.and output(/URL needs to start with/).to_stderr
end
end
@@ -227,7 +223,7 @@ RSpec.describe 'bin/feature-flag' do
expect($stdin).to receive(:gets).and_return(url)
expect do
expect(described_class.read_rollout_issue_url(options)).to eq('https://issue')
- end.to output(/Paste URL of `rollout issue` here/).to_stdout
+ end.to output(/URL of the rollout issue/).to_stdout
end
context 'invalid URL given' do
@@ -239,7 +235,7 @@ RSpec.describe 'bin/feature-flag' do
expect do
expect { described_class.read_rollout_issue_url(options) }.to raise_error(/EOF/)
- end.to output(/Paste URL of `rollout issue` here/).to_stdout
+ end.to output(/URL of the rollout issue/).to_stdout
.and output(/URL needs to start/).to_stderr
end
end