Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ef9a63b6
Commit
ef9a63b6
authored
Jul 23, 2020
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify `bin/feature-flag` script
Do not ask for type if it is only one.
parent
e113c30f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
11 deletions
+35
-11
bin/feature-flag
bin/feature-flag
+3
-0
spec/bin/feature_flag_spec.rb
spec/bin/feature_flag_spec.rb
+32
-11
No files found.
bin/feature-flag
View file @
ef9a63b6
...
@@ -118,6 +118,9 @@ class FeatureFlagOptionParser
...
@@ -118,6 +118,9 @@ class FeatureFlagOptionParser
end
end
def
read_type
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
">> Please specify the type of your feature flag:"
$stdout
.
puts
$stdout
.
puts
TYPES
.
each
do
|
type
,
data
|
TYPES
.
each
do
|
type
,
data
|
...
...
spec/bin/feature_flag_spec.rb
View file @
ef9a63b6
...
@@ -115,6 +115,26 @@ RSpec.describe 'bin/feature-flag' do
...
@@ -115,6 +115,26 @@ RSpec.describe 'bin/feature-flag' do
describe
'.read_type'
do
describe
'.read_type'
do
let
(
:type
)
{
'development'
}
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
it
'reads type from $stdin'
do
expect
(
$stdin
).
to
receive
(
:gets
).
and_return
(
type
)
expect
(
$stdin
).
to
receive
(
:gets
).
and_return
(
type
)
expect
do
expect
do
...
@@ -122,7 +142,7 @@ RSpec.describe 'bin/feature-flag' do
...
@@ -122,7 +142,7 @@ RSpec.describe 'bin/feature-flag' do
end
.
to
output
(
/specify the type/
).
to_stdout
end
.
to
output
(
/specify the type/
).
to_stdout
end
end
context
'invalid type
given'
do
context
'when invalid type is
given'
do
let
(
:type
)
{
'invalid'
}
let
(
:type
)
{
'invalid'
}
it
'shows error message and retries'
do
it
'shows error message and retries'
do
...
@@ -136,6 +156,7 @@ RSpec.describe 'bin/feature-flag' do
...
@@ -136,6 +156,7 @@ RSpec.describe 'bin/feature-flag' do
end
end
end
end
end
end
end
describe
'.read_group'
do
describe
'.read_group'
do
let
(
:group
)
{
'group::memory'
}
let
(
:group
)
{
'group::memory'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment