Commit 1dabbb15 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'simplify-bin-feature-flag' into 'master'

Simplify `bin/feature-flag`

See merge request gitlab-org/gitlab!37718
parents 2a91735c ef9a63b6
......@@ -118,6 +118,9 @@ class FeatureFlagOptionParser
end
def read_type
# if there's only one type, do not ask, return
return TYPES.first.first if TYPES.one?
$stdout.puts ">> Please specify the type of your feature flag:"
$stdout.puts
TYPES.each do |type, data|
......
......@@ -115,6 +115,26 @@ RSpec.describe 'bin/feature-flag' do
describe '.read_type' do
let(:type) { 'development' }
context 'when there is only a single type defined' do
before do
stub_const('FeatureFlagOptionParser::TYPES',
development: { description: 'short' }
)
end
it 'returns that type' do
expect(described_class.read_type).to eq(:development)
end
end
context 'when there are many types defined' do
before do
stub_const('FeatureFlagOptionParser::TYPES',
development: { description: 'short' },
licensed: { description: 'licensed' }
)
end
it 'reads type from $stdin' do
expect($stdin).to receive(:gets).and_return(type)
expect do
......@@ -122,7 +142,7 @@ RSpec.describe 'bin/feature-flag' do
end.to output(/specify the type/).to_stdout
end
context 'invalid type given' do
context 'when invalid type is given' do
let(:type) { 'invalid' }
it 'shows error message and retries' do
......@@ -136,6 +156,7 @@ RSpec.describe 'bin/feature-flag' do
end
end
end
end
describe '.read_group' do
let(:group) { 'group::memory' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment