danger-changelog 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/RELEASING.md +67 -0
- data/lib/changelog/changelog_file.rb +10 -5
- data/lib/changelog/changelog_line/changelog_entry_line.rb +59 -0
- data/lib/changelog/changelog_line/changelog_header_line.rb +15 -0
- data/lib/changelog/changelog_line/changelog_line.rb +27 -0
- data/lib/changelog/changelog_line/changelog_line_parser.rb +26 -0
- data/lib/changelog/changelog_line/changelog_placeholder_line.rb +15 -0
- data/lib/changelog/gem_version.rb +1 -1
- data/lib/changelog/plugin.rb +1 -1
- data/lib/danger_plugin.rb +5 -1
- data/spec/changelog_entry_line_spec.rb +168 -0
- data/spec/changelog_file_spec.rb +5 -2
- data/spec/changelog_header_line_spec.rb +104 -0
- data/spec/changelog_line_parser_spec.rb +57 -0
- data/spec/changelog_placeholder_line_spec.rb +58 -0
- data/spec/changelog_spec.rb +4 -1
- data/spec/fixtures/changelogs/with_bad_lines.md +2 -0
- metadata +17 -6
- data/lib/changelog/changelog_line.rb +0 -25
- data/spec/changelog_line_spec.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62a09a0c16544a38bdb2f23068ddb753f1a24703
|
4
|
+
data.tar.gz: 077e72cdb5c66ce5d29643b032e06ba438547a16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 414bd4bb565ccf6600026349257d196535085eaa323720684c829096a1ee212bb4ca85c929f7260ddf040154dc5535aee90a9da9399b8a66cde9d4bd14d333f6
|
7
|
+
data.tar.gz: 434139ee0112b04ff2696113f71750f116010a7d29b70b72ae0217399fb063b659f2f2156300e2cd1c8abf8170bd7becaa3c97bf2919e993d2a301fa0a717085
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
+
### 0.2.1 (12/04/2016)
|
4
|
+
|
5
|
+
* [#17](https://github.com/dblock/danger-changelog/pull/17): Fix: handle CHANGELOG lines that mistakenly start with a symbol other than * - [@antondomashnev](https://github.com/antondomashnev).
|
6
|
+
* [#19](https://github.com/dblock/danger-changelog/pull/19): Added: RELEASING.md document to formalize the process - [@antondomashnev](https://github.com/antondomashnev).
|
7
|
+
* [#20](https://github.com/dblock/danger-changelog/pull/20): Fix: flag extra period and column in CHANGELOG - [@antondomashnev](https://github.com/antondomashnev).
|
8
|
+
|
3
9
|
### 0.2.0 (11/21/2016)
|
4
10
|
|
5
11
|
* [#13](https://github.com/dblock/danger-changelog/pull/13): Fix: suggested CHANGELOG entry may not be of correct format - [@dblock](https://github.com/dblock).
|
data/RELEASING.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Releasing Danger-Changelog
|
2
|
+
|
3
|
+
There're no hard rules about when to release danger-changelog. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
|
4
|
+
|
5
|
+
### Release
|
6
|
+
|
7
|
+
Install bundle, run tests, check that all tests succeed locally.
|
8
|
+
|
9
|
+
```
|
10
|
+
bundle install
|
11
|
+
rake
|
12
|
+
```
|
13
|
+
|
14
|
+
Check that the last build succeeded in [Travis CI](https://travis-ci.org/dblock/danger-changelog) for all supported platforms.
|
15
|
+
|
16
|
+
Increment the version, modify [lib/changelog/gem_version.rb](lib/changelog/gem_version.rb).
|
17
|
+
|
18
|
+
Following the [Semantic Versioning](http://semver.org/):
|
19
|
+
* Increment the third number if the release has bug fixes and/or very minor features with backward compatibility, only (eg. change `0.2.1` to `0.2.2`).
|
20
|
+
* Increment the second number if the release contains major features or breaking API changes (eg. change `0.2.1` to `0.3.0`).
|
21
|
+
|
22
|
+
Create a new version and mark it as Next in [CHANGELOG.md](CHANGELOG.md).
|
23
|
+
|
24
|
+
```
|
25
|
+
### 0.2.2 (12/03/2016)
|
26
|
+
```
|
27
|
+
|
28
|
+
Remove the line with "* Your contribution here.", since there will be no more contributions to this release.
|
29
|
+
|
30
|
+
Commit your changes.
|
31
|
+
|
32
|
+
```
|
33
|
+
git add CHANGELOG.md lib/changelog/gem_version.rb
|
34
|
+
git commit -m "Preparing for release 0.2.2."
|
35
|
+
git push origin master
|
36
|
+
```
|
37
|
+
|
38
|
+
Release.
|
39
|
+
|
40
|
+
```
|
41
|
+
$ rake release
|
42
|
+
|
43
|
+
danger-changelog 0.2.2 built to pkg/danger-changelog-0.2.2.gem.
|
44
|
+
Tagged v0.2.2.
|
45
|
+
Pushed git commits and tags.
|
46
|
+
Pushed danger-changelog 0.2.2 to rubygems.org.
|
47
|
+
```
|
48
|
+
|
49
|
+
### Prepare for the Next Version
|
50
|
+
|
51
|
+
Add the next release to [CHANGELOG.md](CHANGELOG.md).
|
52
|
+
|
53
|
+
```
|
54
|
+
### 0.2.3 (Next)
|
55
|
+
|
56
|
+
* Your contribution here.
|
57
|
+
```
|
58
|
+
|
59
|
+
Increment the third version number in [lib/changelog/gem_version.rb](lib/changelog/gem_version.rb).
|
60
|
+
|
61
|
+
Commit your changes.
|
62
|
+
|
63
|
+
```
|
64
|
+
git add CHANGELOG.md lib/slack/version.rb
|
65
|
+
git commit -m "Preparing for next development iteration, 0.2.3."
|
66
|
+
git push origin master
|
67
|
+
```
|
@@ -38,15 +38,20 @@ module Danger
|
|
38
38
|
@your_contribution_here = false
|
39
39
|
@bad_lines = []
|
40
40
|
File.open(filename).each_line do |line|
|
41
|
-
|
42
|
-
|
41
|
+
next if line.strip.empty?
|
42
|
+
|
43
|
+
changelog_line = ChangelogLineParser.parse(line)
|
44
|
+
|
45
|
+
if changelog_line.nil? || changelog_line.invalid?
|
46
|
+
@bad_lines << line
|
47
|
+
next
|
48
|
+
end
|
49
|
+
|
43
50
|
# notice your contribution here
|
44
|
-
if
|
51
|
+
if changelog_line.is_a?(ChangelogPlaceholderLine)
|
45
52
|
@your_contribution_here = true
|
46
53
|
next
|
47
54
|
end
|
48
|
-
next if Danger::Changelog::ChangelogLine.valid?(line)
|
49
|
-
@bad_lines << line
|
50
55
|
end
|
51
56
|
end
|
52
57
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'changelog/changelog_line/changelog_line'
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
module Changelog
|
5
|
+
# A CHANGELOG.md line represents the change entry.
|
6
|
+
class ChangelogEntryLine < ChangelogLine
|
7
|
+
def valid?
|
8
|
+
return true if line =~ %r{^\*\s[\`[:upper:]].*[^.,] \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\).$}
|
9
|
+
return true if line =~ %r{^\*\s\[\#\d+\]\(https:\/\/github\.com\/.*\d+\)\: [\`[:upper:]].*[^.,] \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\).$}
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.validates_as_changelog_line?(line)
|
14
|
+
matched_rules_count = 0
|
15
|
+
matched_rules_count += 1 if starts_with_star?(line)
|
16
|
+
matched_rules_count += 1 if with_pr_link?(line)
|
17
|
+
matched_rules_count += 1 if with_changelog_description?(line)
|
18
|
+
matched_rules_count += 1 if with_author_link?(line)
|
19
|
+
matched_rules_count >= 2
|
20
|
+
end
|
21
|
+
|
22
|
+
# provide an example of a CHANGELOG line based on a commit message
|
23
|
+
def self.example(github)
|
24
|
+
pr_number = github.pr_json['number']
|
25
|
+
pr_url = github.pr_json['html_url']
|
26
|
+
pr_title = github.pr_title
|
27
|
+
.sub(/[?.!,;]?$/, '')
|
28
|
+
.capitalize
|
29
|
+
pr_author = github.pr_author
|
30
|
+
pr_author_url = "https://github.com/#{github.pr_author}"
|
31
|
+
"* [##{pr_number}](#{pr_url}): #{pr_title} - [@#{pr_author}](#{pr_author_url})."
|
32
|
+
end
|
33
|
+
|
34
|
+
# checks whether line starts with *
|
35
|
+
def self.starts_with_star?(line)
|
36
|
+
return true if line =~ /^\*\s/
|
37
|
+
false
|
38
|
+
end
|
39
|
+
|
40
|
+
# checks whether line contains a MARKDOWN link to a PR
|
41
|
+
def self.with_pr_link?(line)
|
42
|
+
return true if line =~ %r{\[\#\d+\]\(http[s]?:\/\/github\.com\/.*\d+[\/]?\)}
|
43
|
+
false
|
44
|
+
end
|
45
|
+
|
46
|
+
# checks whether line contains a capitalized Text, treated as a description
|
47
|
+
def self.with_changelog_description?(line)
|
48
|
+
return true if line =~ /[\`[:upper:]].*/
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
52
|
+
# checks whether line contains a MARKDOWN link to an author
|
53
|
+
def self.with_author_link?(line)
|
54
|
+
return true if line =~ %r{\[\@[\w\d\-\_]+\]\(http[s]?:\/\/github\.com\/.*[\w\d\-\_]+[\/]?\)}
|
55
|
+
false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Danger
|
2
|
+
module Changelog
|
3
|
+
# A CHANGELOG.md line represents the version header.
|
4
|
+
class ChangelogHeaderLine < ChangelogLine
|
5
|
+
def valid?
|
6
|
+
ChangelogHeaderLine.validates_as_changelog_line?(line)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.validates_as_changelog_line?(line)
|
10
|
+
return true if line =~ /^\#{1,4}\s.+/
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Danger
|
2
|
+
module Changelog
|
3
|
+
# An abstract CHANGELOG.md line.
|
4
|
+
class ChangelogLine
|
5
|
+
attr_accessor :line
|
6
|
+
|
7
|
+
def initialize(line)
|
8
|
+
self.line = line
|
9
|
+
end
|
10
|
+
|
11
|
+
# Match the line with the validation rules
|
12
|
+
def valid?
|
13
|
+
raise 'ChangelogLine subclass must implement the valid? method'
|
14
|
+
end
|
15
|
+
|
16
|
+
# Match the line with the validation rules opposite to valid?
|
17
|
+
def invalid?
|
18
|
+
!valid?
|
19
|
+
end
|
20
|
+
|
21
|
+
# Match the given line if it potentially represents the specific changelog line
|
22
|
+
def self.validates_as_changelog_line?(_line)
|
23
|
+
abort "You need to include a function for #{self} for validates_as_changelog_line?"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'changelog/changelog_line/changelog_entry_line'
|
2
|
+
require 'changelog/changelog_line/changelog_header_line'
|
3
|
+
require 'changelog/changelog_line/changelog_placeholder_line'
|
4
|
+
|
5
|
+
module Danger
|
6
|
+
module Changelog
|
7
|
+
# A parser of the CHANGELOG.md lines
|
8
|
+
class ChangelogLineParser
|
9
|
+
# Returns an instance of Changelog::ChangelogLine class based on the given line
|
10
|
+
def self.parse(line)
|
11
|
+
changelog_line_class = available_changelog_lines.find do |changelog_line|
|
12
|
+
changelog_line.validates_as_changelog_line?(line)
|
13
|
+
end
|
14
|
+
return nil unless changelog_line_class
|
15
|
+
changelog_line_class.new(line)
|
16
|
+
end
|
17
|
+
|
18
|
+
private_class_method
|
19
|
+
|
20
|
+
def self.available_changelog_lines
|
21
|
+
# Order is important
|
22
|
+
[ChangelogPlaceholderLine, ChangelogEntryLine, ChangelogHeaderLine]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Danger
|
2
|
+
module Changelog
|
3
|
+
# A CHANGELOG.md line represents the "Your contribution here".
|
4
|
+
class ChangelogPlaceholderLine < ChangelogLine
|
5
|
+
def valid?
|
6
|
+
ChangelogPlaceholderLine.validates_as_changelog_line?(line)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.validates_as_changelog_line?(line)
|
10
|
+
return true if line == "* Your contribution here.\n"
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/changelog/plugin.rb
CHANGED
@@ -48,7 +48,7 @@ module Danger
|
|
48
48
|
Here's an example of a #{filename} entry:
|
49
49
|
|
50
50
|
```markdown
|
51
|
-
#{Danger::Changelog::
|
51
|
+
#{Danger::Changelog::ChangelogEntryLine.example(github)}
|
52
52
|
```
|
53
53
|
MARKDOWN
|
54
54
|
warn "Unless you're refactoring existing code, please update #{filename}.", sticky: false
|
data/lib/danger_plugin.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
-
require 'changelog/changelog_line'
|
1
|
+
require 'changelog/changelog_line/changelog_entry_line'
|
2
|
+
require 'changelog/changelog_line/changelog_header_line'
|
3
|
+
require 'changelog/changelog_line/changelog_line_parser'
|
4
|
+
require 'changelog/changelog_line/changelog_placeholder_line'
|
5
|
+
require 'changelog/changelog_line/changelog_line'
|
2
6
|
require 'changelog/changelog_file'
|
3
7
|
require 'changelog/plugin'
|
@@ -0,0 +1,168 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Danger::Changelog::ChangelogEntryLine do
|
4
|
+
context 'changelog line' do
|
5
|
+
it 'validates as changelog line' do
|
6
|
+
expect(described_class.validates_as_changelog_line?('* Valid without PR link - [@dblock](https://github.com/dblock).')).to be true
|
7
|
+
expect(described_class.validates_as_changelog_line?('* [#1](https://github.com/dblock/danger-changelog/pull/1): Valid with PR link - [@dblock](https://github.com/dblock).')).to be true
|
8
|
+
expect(described_class.validates_as_changelog_line?('Missing star - [@dblock](https://github.com/dblock).')).to be true
|
9
|
+
expect(described_class.validates_as_changelog_line?('* [#1](https://github.com/dblock/danger-changelog/pull/1) - Not a colon - [@dblock](https://github.com/dblock).')).to be true
|
10
|
+
expect(described_class.validates_as_changelog_line?('* [#1](https://github.com/dblock/danger-changelog/pull/1): No dash [@dblock](https://github.com/dblock).')).to be true
|
11
|
+
expect(described_class.validates_as_changelog_line?('* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)')).to be true
|
12
|
+
expect(described_class.validates_as_changelog_line?('* [#1](https://github.com/dblock/danger-changelog/pull/1): No name.')).to be true
|
13
|
+
expect(described_class.validates_as_changelog_line?('* [#1](https://github.com/dblock/danger-changelog/pull/1): No https in github - [@dblock](http://github.com/dblock).')).to be true
|
14
|
+
expect(described_class.validates_as_changelog_line?('* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra trailing slash - [@dblock](https://github.com/dblock/).')).to be true
|
15
|
+
expect(described_class.validates_as_changelog_line?('# [#1](https://github.com/dblock/danger-changelog/pull/1): Hash instead of star - [@dblock](https://github.com/dblock).')).to be true
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'doesnt validate as changelog line' do
|
19
|
+
expect(described_class.validates_as_changelog_line?('Missing star, PR and author link.')).to be false
|
20
|
+
expect(described_class.validates_as_changelog_line?('* ')).to be false
|
21
|
+
expect(described_class.validates_as_changelog_line?('[@dblock](https://github.com/dblock).')).to be false
|
22
|
+
expect(described_class.validates_as_changelog_line?(' - [@dblock](https://github.com/dblock).')).to be false
|
23
|
+
expect(described_class.validates_as_changelog_line?('[#1](https://github.com/dblock/danger-changelog/pull/1).')).to be false
|
24
|
+
expect(described_class.validates_as_changelog_line?('[#1](https://github.com/dblock/danger-changelog/pull/1): ')).to be false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'changelog entry line' do
|
29
|
+
context 'when without PR link' do
|
30
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('* Valid without PR link - [@antondomashnev](https://github.com/antondomashnev).') }
|
31
|
+
|
32
|
+
it 'is valid' do
|
33
|
+
expect(subject.valid?).to be true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when with PR link' do
|
38
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('* [#1](https://github.com/dblock/danger-changelog/pull/1): Valid with PR link - [@dblock](https://github.com/dblock).') }
|
39
|
+
|
40
|
+
it 'is valid' do
|
41
|
+
expect(subject.valid?).to be true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when missing star' do
|
46
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('Missing star - [@dblock](https://github.com/dblock).') }
|
47
|
+
|
48
|
+
it 'is invalid' do
|
49
|
+
expect(subject.invalid?).to be true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when not a colon' do
|
54
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('* [#1](https://github.com/dblock/danger-changelog/pull/1) - Not a colon - [@dblock](https://github.com/dblock).') }
|
55
|
+
|
56
|
+
it 'is invalid' do
|
57
|
+
expect(subject.invalid?).to be true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when no dash' do
|
62
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('* [#1](https://github.com/dblock/danger-changelog/pull/1): No dash [@dblock](https://github.com/dblock).') }
|
63
|
+
|
64
|
+
it 'is invalid' do
|
65
|
+
expect(subject.invalid?).to be true
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when no final period' do
|
70
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)') }
|
71
|
+
|
72
|
+
it 'is invalid' do
|
73
|
+
expect(subject.invalid?).to be true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when no name' do
|
78
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('* [#1](https://github.com/dblock/danger-changelog/pull/1): No name.') }
|
79
|
+
|
80
|
+
it 'is invalid' do
|
81
|
+
expect(subject.invalid?).to be true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'when no https in GitHub' do
|
86
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('* [#1](https://github.com/dblock/danger-changelog/pull/1): No https in github - [@dblock](http://github.com/dblock).') }
|
87
|
+
|
88
|
+
it 'is invalid' do
|
89
|
+
expect(subject.invalid?).to be true
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when extra trailing slash' do
|
94
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra trailing slash - [@dblock](https://github.com/dblock/).') }
|
95
|
+
|
96
|
+
it 'is invalid' do
|
97
|
+
expect(subject.invalid?).to be true
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'when extra period' do
|
102
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra period. - [@dblock](https://github.com/dblock).') }
|
103
|
+
|
104
|
+
it 'is invalid' do
|
105
|
+
expect(subject.invalid?).to be true
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'when extra colon' do
|
110
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra colon, - [@dblock](https://github.com/dblock).') }
|
111
|
+
|
112
|
+
it 'is invalid' do
|
113
|
+
expect(subject.invalid?).to be true
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'when extra hash' do
|
118
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('* [#1](https://github.com/dblock/danger-changelog/pull/1): With # - [@dblock](https://github.com/dblock).') }
|
119
|
+
|
120
|
+
it 'is valid' do
|
121
|
+
expect(subject.valid?).to be true
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'when with question mark' do
|
126
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('* [#1](https://github.com/dblock/danger-changelog/pull/1): With ? - [@dblock](https://github.com/dblock).') }
|
127
|
+
|
128
|
+
it 'is valid' do
|
129
|
+
expect(subject.valid?).to be true
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'when hash instead of star' do
|
134
|
+
subject { Danger::Changelog::ChangelogEntryLine.new('# [#1](https://github.com/dblock/danger-changelog/pull/1): Hash instead of star - [@dblock](https://github.com/dblock).') }
|
135
|
+
|
136
|
+
it 'is invalid' do
|
137
|
+
expect(subject.invalid?).to be true
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context 'example' do
|
143
|
+
let(:github) do
|
144
|
+
double(Danger::RequestSources::GitHub,
|
145
|
+
pr_json: { 'number' => 123, 'html_url' => 'https://github.com/dblock/danger-changelog/pull/123' },
|
146
|
+
pr_author: 'dblock',
|
147
|
+
pr_title: pr_title)
|
148
|
+
end
|
149
|
+
context 'no transformation required' do
|
150
|
+
let(:pr_title) { 'Test' }
|
151
|
+
it 'uses title as is' do
|
152
|
+
expect(described_class.example(github)).to eq '* [#123](https://github.com/dblock/danger-changelog/pull/123): Test - [@dblock](https://github.com/dblock).'
|
153
|
+
end
|
154
|
+
end
|
155
|
+
context 'with lowercase title' do
|
156
|
+
let(:pr_title) { 'test' }
|
157
|
+
it 'capitalizes it' do
|
158
|
+
expect(described_class.example(github)).to eq '* [#123](https://github.com/dblock/danger-changelog/pull/123): Test - [@dblock](https://github.com/dblock).'
|
159
|
+
end
|
160
|
+
end
|
161
|
+
context 'with a trailing period' do
|
162
|
+
let(:pr_title) { 'Test.' }
|
163
|
+
it 'removes it' do
|
164
|
+
expect(described_class.example(github)).to eq '* [#123](https://github.com/dblock/danger-changelog/pull/123): Test - [@dblock](https://github.com/dblock).'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
data/spec/changelog_file_spec.rb
CHANGED
@@ -42,13 +42,16 @@ describe Danger::Changelog::ChangelogFile do
|
|
42
42
|
end
|
43
43
|
context 'with bad lines' do
|
44
44
|
let(:filename) { File.expand_path('../fixtures/changelogs/with_bad_lines.md', __FILE__) }
|
45
|
-
it 'is
|
45
|
+
it 'is invalid' do
|
46
46
|
expect(subject.bad_lines?).to be true
|
47
47
|
end
|
48
48
|
it 'reports all bad lines' do
|
49
49
|
expect(subject.bad_lines).to eq [
|
50
|
+
"Missing star - [@dblock](https://github.com/dblock).\n",
|
50
51
|
"* [#1](https://github.com/dblock/danger-changelog/pull/1) - Not a colon - [@dblock](https://github.com/dblock).\n",
|
51
|
-
"* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)\n"
|
52
|
+
"* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)\n",
|
53
|
+
"# [#1](https://github.com/dblock/danger-changelog/pull/1): Hash instead of star - [@dblock](https://github.com/dblock).\n",
|
54
|
+
"* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra period. - [@dblock](https://github.com/dblock).\n"
|
52
55
|
]
|
53
56
|
end
|
54
57
|
it 'has your contribution here' do
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Danger::Changelog::ChangelogHeaderLine do
|
4
|
+
context 'changelog line' do
|
5
|
+
it 'validates as changelog line' do
|
6
|
+
expect(described_class.validates_as_changelog_line?('# 1.0.1')).to be true
|
7
|
+
expect(described_class.validates_as_changelog_line?('## Version 1.0.1')).to be true
|
8
|
+
expect(described_class.validates_as_changelog_line?('### Lollypop')).to be true
|
9
|
+
expect(described_class.validates_as_changelog_line?('#### Four hashes is too much')).to be true
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'doesnt validate as changelog line' do
|
13
|
+
expect(described_class.validates_as_changelog_line?('* Star is invalid.')).to be false
|
14
|
+
expect(described_class.validates_as_changelog_line?('It requires a hash symbol')).to be false
|
15
|
+
expect(described_class.validates_as_changelog_line?('1.1.1')).to be false
|
16
|
+
expect(described_class.validates_as_changelog_line?('Version 2.0.1')).to be false
|
17
|
+
expect(described_class.validates_as_changelog_line?('#')).to be false
|
18
|
+
expect(described_class.validates_as_changelog_line?('## ')).to be false
|
19
|
+
expect(described_class.validates_as_changelog_line?('##### I can not validate five')).to be false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'changelog header line' do
|
24
|
+
context 'when one hash symbol' do
|
25
|
+
subject { Danger::Changelog::ChangelogHeaderLine.new('# 1.0.1') }
|
26
|
+
|
27
|
+
it 'is valid' do
|
28
|
+
expect(subject.valid?).to be true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when two hash symbols' do
|
33
|
+
subject { Danger::Changelog::ChangelogHeaderLine.new('## Version 1.0.1') }
|
34
|
+
|
35
|
+
it 'is valid' do
|
36
|
+
expect(subject.valid?).to be true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when three hash symbols' do
|
41
|
+
subject { Danger::Changelog::ChangelogHeaderLine.new('### Lollypop') }
|
42
|
+
|
43
|
+
it 'is valid' do
|
44
|
+
expect(subject.valid?).to be true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when four hash symbols' do
|
49
|
+
subject { Danger::Changelog::ChangelogHeaderLine.new('#### Four hashes is too much') }
|
50
|
+
|
51
|
+
it 'is valid' do
|
52
|
+
expect(subject.valid?).to be true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when no hash symbol' do
|
57
|
+
subject { Danger::Changelog::ChangelogHeaderLine.new('* Star is invalid.') }
|
58
|
+
|
59
|
+
it 'is invalid' do
|
60
|
+
expect(subject.invalid?).to be true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when star instead of hash symbol' do
|
65
|
+
subject { Danger::Changelog::ChangelogHeaderLine.new('* Star is invalid.') }
|
66
|
+
|
67
|
+
it 'is invalid' do
|
68
|
+
expect(subject.invalid?).to be true
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when no hash symbol' do
|
73
|
+
subject { Danger::Changelog::ChangelogHeaderLine.new('It requires hash symbol.') }
|
74
|
+
|
75
|
+
it 'is invalid' do
|
76
|
+
expect(subject.invalid?).to be true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when hash symbol without space' do
|
81
|
+
subject { Danger::Changelog::ChangelogHeaderLine.new('###Lollypop') }
|
82
|
+
|
83
|
+
it 'is invalid' do
|
84
|
+
expect(subject.invalid?).to be true
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'when hash symbol without header title' do
|
89
|
+
subject { Danger::Changelog::ChangelogHeaderLine.new('### ') }
|
90
|
+
|
91
|
+
it 'is invalid' do
|
92
|
+
expect(subject.invalid?).to be true
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'when five hash symbols' do
|
97
|
+
subject { Danger::Changelog::ChangelogHeaderLine.new('##### Tooooo much') }
|
98
|
+
|
99
|
+
it 'is invalid' do
|
100
|
+
expect(subject.invalid?).to be true
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Danger::Changelog::ChangelogLineParser do
|
4
|
+
context 'parse' do
|
5
|
+
context 'changelog entry line' do
|
6
|
+
context 'when valid' do
|
7
|
+
let(:line) { '* [#123](https://github.com/dblock/danger-changelog/pull/123): Test - [@dblock](https://github.com/dblock).' }
|
8
|
+
it 'returns ChangelogEntryLine' do
|
9
|
+
expect(described_class.parse(line)).to be_a(Danger::Changelog::ChangelogEntryLine)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when invalid' do
|
14
|
+
it 'returns ChangelogEntryLine' do
|
15
|
+
expect(described_class.parse('Missing star - [@dblock](https://github.com/dblock).')).to be_a(Danger::Changelog::ChangelogEntryLine)
|
16
|
+
expect(described_class.parse('* [#1](https://github.com/dblock/danger-changelog/pull/1) - Not a colon - [@dblock](https://github.com/dblock).')).to be_a(Danger::Changelog::ChangelogEntryLine)
|
17
|
+
expect(described_class.parse('* [#1](https://github.com/dblock/danger-changelog/pull/1): No dash [@dblock](https://github.com/dblock).')).to be_a(Danger::Changelog::ChangelogEntryLine)
|
18
|
+
expect(described_class.parse('* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)')).to be_a(Danger::Changelog::ChangelogEntryLine)
|
19
|
+
expect(described_class.parse('* [#1](https://github.com/dblock/danger-changelog/pull/1): No name.')).to be_a(Danger::Changelog::ChangelogEntryLine)
|
20
|
+
expect(described_class.parse('* [#1](https://github.com/dblock/danger-changelog/pull/1): No https in github - [@dblock](http://github.com/dblock).')).to be_a(Danger::Changelog::ChangelogEntryLine)
|
21
|
+
expect(described_class.parse('* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra trailing slash - [@dblock](https://github.com/dblock/).')).to be_a(Danger::Changelog::ChangelogEntryLine)
|
22
|
+
expect(described_class.parse('# [#1](https://github.com/dblock/danger-changelog/pull/1): Hash instead of star - [@dblock](https://github.com/dblock).')).to be_a(Danger::Changelog::ChangelogEntryLine)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'changelog your contribution here line' do
|
28
|
+
let(:line) { "* Your contribution here.\n" }
|
29
|
+
it 'returns ChangelogPlaceholderLine' do
|
30
|
+
expect(described_class.parse(line)).to be_a(Danger::Changelog::ChangelogPlaceholderLine)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'changelog header line' do
|
35
|
+
context 'when one hash' do
|
36
|
+
let(:line) { '# Version 1.1.1' }
|
37
|
+
it 'returns ChangelogHeaderLine' do
|
38
|
+
expect(described_class.parse(line)).to be_a(Danger::Changelog::ChangelogHeaderLine)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when two hashes' do
|
43
|
+
let(:line) { '## Version 1.1.1' }
|
44
|
+
it 'returns ChangelogHeaderLine' do
|
45
|
+
expect(described_class.parse(line)).to be_a(Danger::Changelog::ChangelogHeaderLine)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when three hashes' do
|
50
|
+
let(:line) { '### Version 1.1.1' }
|
51
|
+
it 'returns ChangelogHeaderLine' do
|
52
|
+
expect(described_class.parse(line)).to be_a(Danger::Changelog::ChangelogHeaderLine)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Danger::Changelog::ChangelogPlaceholderLine do
|
4
|
+
context 'changelog line' do
|
5
|
+
it 'validates as changelog line' do
|
6
|
+
expect(described_class.validates_as_changelog_line?("* Your contribution here.\n")).to be true
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'doesnt validate as changelog line' do
|
10
|
+
expect(described_class.validates_as_changelog_line?('* Your contribution here.')).to be false
|
11
|
+
expect(described_class.validates_as_changelog_line?("* Your contribution here\n")).to be false
|
12
|
+
expect(described_class.validates_as_changelog_line?("* Put your contribution here.\n")).to be false
|
13
|
+
expect(described_class.validates_as_changelog_line?("Your contribution here.\n")).to be false
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'changelog placeholder line' do
|
17
|
+
context 'when exactly expected string' do
|
18
|
+
subject { Danger::Changelog::ChangelogPlaceholderLine.new("* Your contribution here.\n") }
|
19
|
+
|
20
|
+
it 'is valid' do
|
21
|
+
expect(subject.valid?).to be true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when without new line' do
|
26
|
+
subject { Danger::Changelog::ChangelogPlaceholderLine.new('* Your contribution here.') }
|
27
|
+
|
28
|
+
it 'is invalid' do
|
29
|
+
expect(subject.invalid?).to be true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when no final period' do
|
34
|
+
subject { Danger::Changelog::ChangelogPlaceholderLine.new("* Your contribution here\n") }
|
35
|
+
|
36
|
+
it 'is invalid' do
|
37
|
+
expect(subject.invalid?).to be true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when text doesnt match' do
|
42
|
+
subject { Danger::Changelog::ChangelogPlaceholderLine.new("* Put your contribution here.\n") }
|
43
|
+
|
44
|
+
it 'is invalid' do
|
45
|
+
expect(subject.invalid?).to be true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when there is not star' do
|
50
|
+
subject { Danger::Changelog::ChangelogPlaceholderLine.new("Your contribution here.\n") }
|
51
|
+
|
52
|
+
it 'is invalid' do
|
53
|
+
expect(subject.invalid?).to be true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/spec/changelog_spec.rb
CHANGED
@@ -128,8 +128,11 @@ describe Danger::Changelog do
|
|
128
128
|
expect(status_report[:errors]).to eq ["One of the lines below found in #{filename} doesn't match the expected format. Please make it look like the other lines, pay attention to periods and spaces."]
|
129
129
|
expect(status_report[:warnings]).to eq []
|
130
130
|
expect(status_report[:markdowns].map(&:message)).to eq [
|
131
|
+
"```markdown\nMissing star - [@dblock](https://github.com/dblock).\n```\n",
|
131
132
|
"```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1) - Not a colon - [@dblock](https://github.com/dblock).\n```\n",
|
132
|
-
"```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)\n```\n"
|
133
|
+
"```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)\n```\n",
|
134
|
+
"```markdown\n# [#1](https://github.com/dblock/danger-changelog/pull/1): Hash instead of star - [@dblock](https://github.com/dblock).\n```\n",
|
135
|
+
"```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra period. - [@dblock](https://github.com/dblock).\n```\n"
|
133
136
|
]
|
134
137
|
end
|
135
138
|
end
|
@@ -3,4 +3,6 @@
|
|
3
3
|
Missing star - [@dblock](https://github.com/dblock).
|
4
4
|
* [#1](https://github.com/dblock/danger-changelog/pull/1) - Not a colon - [@dblock](https://github.com/dblock).
|
5
5
|
* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)
|
6
|
+
# [#1](https://github.com/dblock/danger-changelog/pull/1): Hash instead of star - [@dblock](https://github.com/dblock).
|
7
|
+
* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra period. - [@dblock](https://github.com/dblock).
|
6
8
|
* Your contribution here.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-changelog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dblock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -169,18 +169,26 @@ files:
|
|
169
169
|
- Guardfile
|
170
170
|
- LICENSE.txt
|
171
171
|
- README.md
|
172
|
+
- RELEASING.md
|
172
173
|
- Rakefile
|
173
174
|
- danger-changelog.gemspec
|
174
175
|
- images/have_you_updated_changelog.png
|
175
176
|
- images/is_changelog_format_correct.png
|
176
177
|
- lib/changelog/changelog_file.rb
|
177
|
-
- lib/changelog/changelog_line.rb
|
178
|
+
- lib/changelog/changelog_line/changelog_entry_line.rb
|
179
|
+
- lib/changelog/changelog_line/changelog_header_line.rb
|
180
|
+
- lib/changelog/changelog_line/changelog_line.rb
|
181
|
+
- lib/changelog/changelog_line/changelog_line_parser.rb
|
182
|
+
- lib/changelog/changelog_line/changelog_placeholder_line.rb
|
178
183
|
- lib/changelog/gem_version.rb
|
179
184
|
- lib/changelog/plugin.rb
|
180
185
|
- lib/danger_changelog.rb
|
181
186
|
- lib/danger_plugin.rb
|
187
|
+
- spec/changelog_entry_line_spec.rb
|
182
188
|
- spec/changelog_file_spec.rb
|
183
|
-
- spec/
|
189
|
+
- spec/changelog_header_line_spec.rb
|
190
|
+
- spec/changelog_line_parser_spec.rb
|
191
|
+
- spec/changelog_placeholder_line_spec.rb
|
184
192
|
- spec/changelog_spec.rb
|
185
193
|
- spec/fixtures/changelogs/minimal.md
|
186
194
|
- spec/fixtures/changelogs/missing_your_contribution_here.md
|
@@ -206,13 +214,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
214
|
version: '0'
|
207
215
|
requirements: []
|
208
216
|
rubyforge_project:
|
209
|
-
rubygems_version: 2.
|
217
|
+
rubygems_version: 2.5.1
|
210
218
|
signing_key:
|
211
219
|
specification_version: 4
|
212
220
|
summary: A danger.systems plugin that is OCD about your CHANGELOG.
|
213
221
|
test_files:
|
222
|
+
- spec/changelog_entry_line_spec.rb
|
214
223
|
- spec/changelog_file_spec.rb
|
215
|
-
- spec/
|
224
|
+
- spec/changelog_header_line_spec.rb
|
225
|
+
- spec/changelog_line_parser_spec.rb
|
226
|
+
- spec/changelog_placeholder_line_spec.rb
|
216
227
|
- spec/changelog_spec.rb
|
217
228
|
- spec/fixtures/changelogs/minimal.md
|
218
229
|
- spec/fixtures/changelogs/missing_your_contribution_here.md
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Danger
|
2
|
-
module Changelog
|
3
|
-
# A CHANGELOG.md file reader.
|
4
|
-
module ChangelogLine
|
5
|
-
# match the PR format, with or without PR number
|
6
|
-
def self.valid?(line)
|
7
|
-
return true if line =~ %r{^\*\s[\`[:upper:]].* \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\)\.$}
|
8
|
-
return true if line =~ %r{^\*\s\[\#\d+\]\(https:\/\/github\.com\/.*\d+\)\: [\`[:upper:]].* \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\)\.$}
|
9
|
-
false
|
10
|
-
end
|
11
|
-
|
12
|
-
# provide an example of a CHANGELOG line based on a commit message
|
13
|
-
def self.example(github)
|
14
|
-
pr_number = github.pr_json['number']
|
15
|
-
pr_url = github.pr_json['html_url']
|
16
|
-
pr_title = github.pr_title
|
17
|
-
.sub(/[?.!,;]?$/, '')
|
18
|
-
.capitalize
|
19
|
-
pr_author = github.pr_author
|
20
|
-
pr_author_url = "https://github.com/#{github.pr_author}"
|
21
|
-
"* [##{pr_number}](#{pr_url}): #{pr_title} - [@#{pr_author}](#{pr_author_url})."
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/spec/changelog_line_spec.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require File.expand_path('../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe Danger::Changelog::ChangelogLine do
|
4
|
-
context 'lines' do
|
5
|
-
it 'valid lines' do
|
6
|
-
expect(subject.valid?('* Reticluated spline - [@dblock](https://github.com/dblock).')).to be true
|
7
|
-
expect(subject.valid?('* [#1](https://github.com/dblock/danger-changelog/pull/1): Reticluated spline - [@dblock](https://github.com/dblock).')).to be true
|
8
|
-
end
|
9
|
-
it 'invalid lines' do
|
10
|
-
expect(subject.valid?('Missing star - [@dblock](https://github.com/dblock).')).to be false
|
11
|
-
expect(subject.valid?('* [#1](https://github.com/dblock/danger-changelog/pull/1) - Not a colon - [@dblock](https://github.com/dblock).')).to be false
|
12
|
-
expect(subject.valid?('* [#1](https://github.com/dblock/danger-changelog/pull/1): No dash [@dblock](https://github.com/dblock).')).to be false
|
13
|
-
expect(subject.valid?('* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)')).to be false
|
14
|
-
expect(subject.valid?('* [#1](https://github.com/dblock/danger-changelog/pull/1): No name.')).to be false
|
15
|
-
expect(subject.valid?('* [#1](https://github.com/dblock/danger-changelog/pull/1): No https in github - [@dblock](http://github.com/dblock).')).to be false
|
16
|
-
expect(subject.valid?('* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra trailing slash - [@dblock](https://github.com/dblock/).')).to be false
|
17
|
-
end
|
18
|
-
end
|
19
|
-
context 'example' do
|
20
|
-
let(:github) do
|
21
|
-
double(Danger::RequestSources::GitHub,
|
22
|
-
pr_json: { 'number' => 123, 'html_url' => 'https://github.com/dblock/danger-changelog/pull/123' },
|
23
|
-
pr_author: 'dblock',
|
24
|
-
pr_title: pr_title)
|
25
|
-
end
|
26
|
-
context 'no transformation required' do
|
27
|
-
let(:pr_title) { 'Test' }
|
28
|
-
it 'uses title as is' do
|
29
|
-
expect(subject.example(github)).to eq '* [#123](https://github.com/dblock/danger-changelog/pull/123): Test - [@dblock](https://github.com/dblock).'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
context 'with lowercase title' do
|
33
|
-
let(:pr_title) { 'test' }
|
34
|
-
it 'capitalizes it' do
|
35
|
-
expect(subject.example(github)).to eq '* [#123](https://github.com/dblock/danger-changelog/pull/123): Test - [@dblock](https://github.com/dblock).'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
context 'with a trailing period' do
|
39
|
-
let(:pr_title) { 'Test.' }
|
40
|
-
it 'removes it' do
|
41
|
-
expect(subject.example(github)).to eq '* [#123](https://github.com/dblock/danger-changelog/pull/123): Test - [@dblock](https://github.com/dblock).'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|