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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
5acb3230
Commit
5acb3230
authored
Oct 29, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for ChangelogOptionParser in bin/changelog
parent
23312b48
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
1 deletion
+67
-1
bin/changelog
bin/changelog
+2
-1
spec/bin/changelog_spec.rb
spec/bin/changelog_spec.rb
+65
-0
No files found.
bin/changelog
View file @
5acb3230
...
@@ -42,7 +42,7 @@ class ChangelogOptionParser
...
@@ -42,7 +42,7 @@ class ChangelogOptionParser
end
end
opts
.
on
(
'-h'
,
'--help'
,
'Print help message'
)
do
opts
.
on
(
'-h'
,
'--help'
,
'Print help message'
)
do
puts
opts
$stdout
.
puts
opts
exit
exit
end
end
end
end
...
@@ -72,6 +72,7 @@ class ChangelogEntry
...
@@ -72,6 +72,7 @@ class ChangelogEntry
$stdout
.
puts
"
\e
[32mcreate
\e
[0m
#{
file_path
}
"
$stdout
.
puts
"
\e
[32mcreate
\e
[0m
#{
file_path
}
"
$stdout
.
puts
contents
$stdout
.
puts
contents
unless
options
.
dry_run
unless
options
.
dry_run
write
write
amend_commit
if
options
.
amend
amend_commit
if
options
.
amend
...
...
spec/bin/changelog_spec.rb
0 → 100644
View file @
5acb3230
require
'spec_helper'
load
File
.
expand_path
(
'../../bin/changelog'
,
__dir__
)
describe
'bin/changelog'
do
describe
ChangelogOptionParser
do
it
'parses --ammend'
do
options
=
described_class
.
parse
(
%w[foo bar --amend]
)
expect
(
options
.
amend
).
to
eq
true
end
it
'parses --merge-request'
do
options
=
described_class
.
parse
(
%w[foo --merge-request 1234 bar]
)
expect
(
options
.
merge_request
).
to
eq
1234
end
it
'parses -m'
do
options
=
described_class
.
parse
(
%w[foo -m 4321 bar]
)
expect
(
options
.
merge_request
).
to
eq
4321
end
it
'parses --dry-run'
do
options
=
described_class
.
parse
(
%w[foo --dry-run bar]
)
expect
(
options
.
dry_run
).
to
eq
true
end
it
'parses -n'
do
options
=
described_class
.
parse
(
%w[foo -n bar]
)
expect
(
options
.
dry_run
).
to
eq
true
end
it
'parses --git-username'
do
allow
(
described_class
).
to
receive
(
:git_user_name
).
and_return
(
'Jane Doe'
)
options
=
described_class
.
parse
(
%w[foo --git-username bar]
)
expect
(
options
.
author
).
to
eq
'Jane Doe'
end
it
'parses -u'
do
allow
(
described_class
).
to
receive
(
:git_user_name
).
and_return
(
'John Smith'
)
options
=
described_class
.
parse
(
%w[foo -u bar]
)
expect
(
options
.
author
).
to
eq
'John Smith'
end
it
'parses -h'
do
expect
do
$stdout
=
StringIO
.
new
described_class
.
parse
(
%w[foo -h bar]
)
end
.
to
raise_error
(
SystemExit
)
end
it
'assigns title'
do
options
=
described_class
.
parse
(
%W[foo -m 1 bar
\n
-u baz
\r\n
--amend]
)
expect
(
options
.
title
).
to
eq
'foo bar baz'
end
end
end
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