Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/gitlab/cli_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,16 @@ def symbolize_keys(hash)
hash
end

# Check if arg is a color in 6-digit hex notation with leading '#' sign
def hex_color?(arg)
pattern = /\A#\h{6}\Z/

pattern.match(arg)
end

# YAML::load on a single argument
def yaml_load(arg)
YAML.safe_load(arg)
hex_color?(arg) ? arg : YAML.safe_load(arg)
rescue Psych::SyntaxError
raise "Error: Argument is not valid YAML syntax: #{arg}"
end
Expand Down
12 changes: 12 additions & 0 deletions spec/gitlab/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@
expect(@output).to include('Jack Smith')
end
end

context 'when command is create_label' do
before do
stub_post('/projects/Project/labels', 'label')
args = ['Project', 'Backlog', '#DD10AA']
@output = capture_output { described_class.run('create_label', args) }
end

it 'shows executed command' do
expect(@output).to include('Gitlab.create_label Project, Backlog, #DD10AA')
end
end
end

describe '.start' do
Expand Down