danger-changelog 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/danger.yml +23 -0
- data/.github/workflows/lint.yml +16 -0
- data/.github/workflows/test.yml +20 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +10 -0
- data/.rubocop_todo.yml +1 -39
- data/CHANGELOG.md +11 -0
- data/CONTRIBUTING.md +1 -1
- data/Dangerfile +1 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +1 -1
- data/README.md +20 -3
- data/RELEASING.md +1 -1
- data/danger-changelog.gemspec +0 -11
- data/lib/changelog/changelog_file.rb +5 -3
- data/lib/changelog/changelog_line/changelog_entry_line.rb +31 -1
- data/lib/changelog/changelog_line/changelog_header_line.rb +2 -2
- data/lib/changelog/changelog_line/changelog_line.rb +2 -0
- data/lib/changelog/changelog_line/changelog_line_parser.rb +2 -2
- data/lib/changelog/config.rb +4 -2
- data/lib/changelog/gem_version.rb +1 -1
- data/lib/changelog/parsers/base.rb +2 -2
- data/lib/changelog/parsers/intridea_format.rb +2 -1
- data/lib/changelog/parsers/keep_a_changelog.rb +2 -2
- data/lib/changelog/parsers/validation_result.rb +31 -0
- data/lib/changelog/parsers.rb +1 -0
- data/lib/changelog/plugin.rb +10 -9
- data/spec/changelog_spec.rb +88 -254
- data/spec/config_spec.rb +11 -3
- data/spec/{changelog_entry_line_spec.rb → intridea/changelog_entry_line_spec.rb} +1 -1
- data/spec/intridea/changelog_file_spec.rb +120 -0
- data/spec/{changelog_header_line_spec.rb → intridea/changelog_header_line_spec.rb} +1 -1
- data/spec/{changelog_line_parser_spec.rb → intridea/changelog_line_parser_spec.rb} +1 -1
- data/spec/{changelog_placeholder_line_spec.rb → intridea/changelog_placeholder_line_spec.rb} +5 -3
- data/spec/intridea/changelog_spec.rb +150 -0
- data/spec/{fixtures/changelogs → intridea/fixtures}/dates.md +3 -0
- data/spec/intridea/fixtures/extra_trailing_space.md +3 -0
- data/spec/keep_a_changelog/changelog_spec.rb +84 -0
- data/spec/keep_a_changelog/fixtures/invalid_line.md +23 -0
- data/spec/keep_a_changelog/fixtures/lines_with_links.md +14 -0
- data/spec/keep_a_changelog/fixtures/missing_a_version_header.md +20 -0
- data/spec/plugin_spec.rb +10 -0
- metadata +50 -173
- data/.travis.yml +0 -14
- data/spec/changelog_file_spec.rb +0 -110
- /data/spec/{fixtures/changelogs → intridea/fixtures}/customized.md +0 -0
- /data/spec/{fixtures/changelogs → intridea/fixtures}/imbalanced.md +0 -0
- /data/spec/{fixtures/changelogs → intridea/fixtures}/lines.md +0 -0
- /data/spec/{fixtures/changelogs → intridea/fixtures}/minimal.md +0 -0
- /data/spec/{fixtures/changelogs → intridea/fixtures}/missing_your_contribution_here.md +0 -0
- /data/spec/{fixtures/changelogs → intridea/fixtures}/semver.md +0 -0
- /data/spec/{fixtures/changelogs/keep_a_changelog.md → keep_a_changelog/fixtures/complete.md} +0 -0
data/spec/changelog_spec.rb
CHANGED
@@ -1,312 +1,146 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Danger::Changelog do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
describe '
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
it 'placeholder_line' do
|
19
|
-
expect(changelog.placeholder_line).to eq "* Your contribution here.\n"
|
20
|
-
end
|
4
|
+
let(:dangerfile) { testing_dangerfile }
|
5
|
+
let(:changelog) { dangerfile.changelog }
|
6
|
+
let(:status_report) { changelog.status_report }
|
7
|
+
|
8
|
+
describe 'in a PR' do
|
9
|
+
before do
|
10
|
+
changelog.env.request_source.pr_json = {
|
11
|
+
'number' => 123,
|
12
|
+
'title' => 'being dangerous',
|
13
|
+
'html_url' => 'https://github.com/dblock/danger-changelog/pull/123',
|
14
|
+
'user' => {
|
15
|
+
'login' => 'dblock'
|
16
|
+
}
|
17
|
+
}
|
21
18
|
end
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
changelog.env.request_source.pr_json = {
|
27
|
-
'number' => 123,
|
28
|
-
'title' => 'being dangerous',
|
29
|
-
'html_url' => 'https://github.com/dblock/danger-changelog/pull/123',
|
30
|
-
'user' => {
|
31
|
-
'login' => 'dblock'
|
32
|
-
}
|
33
|
-
}
|
20
|
+
context 'check!' do
|
21
|
+
subject do
|
22
|
+
changelog.check!
|
34
23
|
end
|
35
24
|
|
36
|
-
context '
|
37
|
-
|
38
|
-
changelog.
|
25
|
+
context 'without CHANGELOG changes' do
|
26
|
+
before do
|
27
|
+
allow(changelog.git).to receive(:modified_files).and_return(['some-file.txt'])
|
28
|
+
allow(changelog.git).to receive(:added_files).and_return(['some-file.txt'])
|
39
29
|
end
|
40
30
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'complains when no CHANGELOG can be found' do
|
49
|
-
expect(subject).to be false
|
50
|
-
expect(status_report[:errors]).to eq []
|
51
|
-
expect(status_report[:warnings]).to eq ["Unless you're refactoring existing code or improving documentation, please update #{filename}."]
|
52
|
-
expect(status_report[:markdowns].map(&:message)).to eq ["Here's an example of a #{filename} entry:\n\n```markdown\n* [#123](https://github.com/dblock/danger-changelog/pull/123): Being dangerous - [@dblock](https://github.com/dblock).\n```\n"]
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'with a README.md' do
|
57
|
-
before do
|
58
|
-
allow(changelog.git).to receive(:modified_files).and_return(['README.md'])
|
59
|
-
allow(changelog.git).to receive(:added_files).and_return([])
|
60
|
-
end
|
61
|
-
it 'has no complaints' do
|
62
|
-
expect(subject).to be true
|
63
|
-
expect(status_report[:errors]).to eq []
|
64
|
-
expect(status_report[:warnings]).to eq []
|
65
|
-
expect(status_report[:markdowns]).to eq []
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'with files being ignored' do
|
70
|
-
context 'name' do
|
71
|
-
before do
|
72
|
-
changelog.ignore_files = ['WHATEVER.md']
|
73
|
-
allow(changelog.git).to receive(:modified_files).and_return(['WHATEVER.md'])
|
74
|
-
allow(changelog.git).to receive(:added_files).and_return([])
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'has no complaints' do
|
78
|
-
expect(subject).to be true
|
79
|
-
expect(status_report[:errors]).to eq []
|
80
|
-
expect(status_report[:warnings]).to eq []
|
81
|
-
expect(status_report[:markdowns]).to eq []
|
82
|
-
end
|
83
|
-
end
|
84
|
-
context 'mixed' do
|
85
|
-
before do
|
86
|
-
changelog.ignore_files = ['WHATEVER.md', /\.txt$/]
|
87
|
-
allow(changelog.git).to receive(:modified_files).and_return(['WHATEVER.md'])
|
88
|
-
allow(changelog.git).to receive(:added_files).and_return(['one.txt', 'two.txt'])
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'has no complaints' do
|
92
|
-
expect(subject).to be true
|
93
|
-
expect(status_report[:errors]).to eq []
|
94
|
-
expect(status_report[:warnings]).to eq []
|
95
|
-
expect(status_report[:markdowns]).to eq []
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
31
|
+
it 'complains when no CHANGELOG can be found' do
|
32
|
+
expect(subject).to be false
|
33
|
+
expect(status_report[:errors]).to eq []
|
34
|
+
expect(status_report[:warnings]).to eq ["Unless you're refactoring existing code or improving documentation, please update CHANGELOG.md."]
|
35
|
+
expect(status_report[:markdowns].map(&:message)).to eq ["Here's an example of a CHANGELOG.md entry:\n\n```markdown\n* [#123](https://github.com/dblock/danger-changelog/pull/123): Being dangerous - [@dblock](https://github.com/dblock).\n```\n"]
|
99
36
|
end
|
37
|
+
end
|
100
38
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'has no complaints' do
|
108
|
-
expect(subject).to be true
|
109
|
-
expect(status_report[:errors]).to eq []
|
110
|
-
expect(status_report[:warnings]).to eq []
|
111
|
-
expect(status_report[:markdowns]).to eq []
|
112
|
-
end
|
39
|
+
context 'with CHANGELOG changes' do
|
40
|
+
before do
|
41
|
+
allow(changelog.git).to receive(:modified_files).and_return([changelog.filename])
|
42
|
+
allow(changelog.git).to receive(:added_files).and_return([])
|
113
43
|
end
|
114
44
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
it 'has no complaints' do
|
122
|
-
expect(subject).to be true
|
123
|
-
expect(status_report[:errors]).to eq []
|
124
|
-
expect(status_report[:warnings]).to eq []
|
125
|
-
expect(status_report[:markdowns]).to eq []
|
126
|
-
end
|
45
|
+
it 'has no complaints' do
|
46
|
+
expect(subject).to be true
|
47
|
+
expect(status_report[:errors]).to eq []
|
48
|
+
expect(status_report[:warnings]).to eq []
|
49
|
+
expect(status_report[:markdowns]).to eq []
|
127
50
|
end
|
128
51
|
end
|
52
|
+
end
|
129
53
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
end
|
54
|
+
context 'have_you_updated_changelog?' do
|
55
|
+
subject do
|
56
|
+
changelog.have_you_updated_changelog?
|
57
|
+
end
|
135
58
|
|
136
|
-
|
137
|
-
|
138
|
-
|
59
|
+
context 'without CHANGELOG changes' do
|
60
|
+
context 'when something was modified' do
|
61
|
+
before do
|
62
|
+
allow(changelog.git).to receive(:modified_files).and_return(['some-file.txt'])
|
63
|
+
allow(changelog.git).to receive(:added_files).and_return(['another-file.txt'])
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'complains when no CHANGELOG can be found' do
|
139
67
|
expect(subject).to be false
|
140
|
-
expect(status_report[:errors]).to eq [
|
68
|
+
expect(status_report[:errors]).to eq []
|
69
|
+
expect(status_report[:warnings]).to eq ["Unless you're refactoring existing code or improving documentation, please update #{changelog.filename}."]
|
70
|
+
expect(status_report[:markdowns].map(&:message)).to eq ["Here's an example of a #{changelog.filename} entry:\n\n```markdown\n* [#123](https://github.com/dblock/danger-changelog/pull/123): Being dangerous - [@dblock](https://github.com/dblock).\n```\n"]
|
141
71
|
end
|
142
72
|
end
|
143
73
|
|
144
|
-
context 'with
|
74
|
+
context 'with a README.md' do
|
145
75
|
before do
|
146
|
-
allow(changelog.git).to receive(:modified_files).and_return([
|
76
|
+
allow(changelog.git).to receive(:modified_files).and_return(['README.md'])
|
147
77
|
allow(changelog.git).to receive(:added_files).and_return([])
|
148
78
|
end
|
149
|
-
|
150
79
|
it 'has no complaints' do
|
151
80
|
expect(subject).to be true
|
152
81
|
expect(status_report[:errors]).to eq []
|
153
82
|
expect(status_report[:warnings]).to eq []
|
154
83
|
expect(status_report[:markdowns]).to eq []
|
155
84
|
end
|
85
|
+
end
|
156
86
|
|
157
|
-
|
87
|
+
context 'with files being ignored' do
|
88
|
+
context 'name' do
|
158
89
|
before do
|
159
|
-
changelog.
|
90
|
+
changelog.ignore_files = ['WHATEVER.md']
|
91
|
+
allow(changelog.git).to receive(:modified_files).and_return(['WHATEVER.md'])
|
92
|
+
allow(changelog.git).to receive(:added_files).and_return([])
|
160
93
|
end
|
161
94
|
|
162
|
-
|
163
|
-
it 'is ok' do
|
95
|
+
it 'has no complaints' do
|
164
96
|
expect(subject).to be true
|
165
97
|
expect(status_report[:errors]).to eq []
|
166
98
|
expect(status_report[:warnings]).to eq []
|
167
99
|
expect(status_report[:markdowns]).to eq []
|
168
100
|
end
|
169
101
|
end
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
before do
|
176
|
-
changelog.placeholder_line = "* Nothing yet.\n"
|
177
|
-
end
|
178
|
-
|
179
|
-
it 'complains' do
|
180
|
-
expect(subject).to be false
|
181
|
-
expect(status_report[:errors]).to eq ["Please put back the `* Nothing yet.` line into #{filename}."]
|
182
|
-
expect(status_report[:warnings]).to eq []
|
183
|
-
expect(status_report[:markdowns]).to eq []
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
context 'when placeholder line is default' do
|
188
|
-
it 'complains' do
|
189
|
-
expect(subject).to be false
|
190
|
-
expect(status_report[:errors]).to eq ["Please put back the `* Your contribution here.` line into #{filename}."]
|
191
|
-
expect(status_report[:warnings]).to eq []
|
192
|
-
expect(status_report[:markdowns]).to eq []
|
193
|
-
end
|
102
|
+
context 'mixed' do
|
103
|
+
before do
|
104
|
+
changelog.ignore_files = ['WHATEVER.md', /\.txt$/]
|
105
|
+
allow(changelog.git).to receive(:modified_files).and_return(['WHATEVER.md'])
|
106
|
+
allow(changelog.git).to receive(:added_files).and_return(['one.txt', 'two.txt'])
|
194
107
|
end
|
195
108
|
|
196
|
-
|
197
|
-
before do
|
198
|
-
changelog.placeholder_line = nil
|
199
|
-
end
|
200
|
-
|
201
|
-
it 'is ok' do
|
202
|
-
expect(subject).to be true
|
203
|
-
expect(status_report[:errors]).to eq []
|
204
|
-
expect(status_report[:warnings]).to eq []
|
205
|
-
expect(status_report[:markdowns]).to eq []
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
context 'minimal example' do
|
211
|
-
let(:filename) { File.expand_path('fixtures/changelogs/minimal.md', __dir__) }
|
212
|
-
it 'is ok' do
|
109
|
+
it 'has no complaints' do
|
213
110
|
expect(subject).to be true
|
214
111
|
expect(status_report[:errors]).to eq []
|
215
112
|
expect(status_report[:warnings]).to eq []
|
216
113
|
expect(status_report[:markdowns]).to eq []
|
217
114
|
end
|
218
|
-
|
219
|
-
context 'when placeholder line is nil' do
|
220
|
-
before do
|
221
|
-
changelog.placeholder_line = nil
|
222
|
-
end
|
223
|
-
|
224
|
-
it 'complains' do
|
225
|
-
expect(subject).to be false
|
226
|
-
expect(status_report[:errors]).to eq ["One of the lines below found in #{filename} doesn't match the [expected format](https://github.com/dblock/danger-changelog/blob/master/README.md#whats-a-correctly-formatted-changelog-file). Please make it look like the other lines, pay attention to version numbers, periods, spaces and date formats."]
|
227
|
-
expect(status_report[:warnings]).to eq []
|
228
|
-
expect(status_report[:markdowns].map(&:message)).to eq [
|
229
|
-
"```markdown\n* Your contribution here.\n```\n"
|
230
|
-
]
|
231
|
-
end
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
context 'with bad lines' do
|
236
|
-
let(:filename) { File.expand_path('fixtures/changelogs/lines.md', __dir__) }
|
237
|
-
it 'complains' do
|
238
|
-
expect(subject).to be false
|
239
|
-
expect(status_report[:errors]).to eq ["One of the lines below found in #{filename} doesn't match the [expected format](https://github.com/dblock/danger-changelog/blob/master/README.md#whats-a-correctly-formatted-changelog-file). Please make it look like the other lines, pay attention to version numbers, periods, spaces and date formats."]
|
240
|
-
expect(status_report[:warnings]).to eq []
|
241
|
-
expect(status_report[:markdowns].map(&:message)).to eq [
|
242
|
-
"```markdown\nMissing star - [@dblock](https://github.com/dblock).\n```\n",
|
243
|
-
"```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1) - Not a colon - [@dblock](https://github.com/dblock).\n```\n",
|
244
|
-
"```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)\n```\n",
|
245
|
-
"```markdown\n# [#1](https://github.com/dblock/danger-changelog/pull/1): Hash instead of star - [@dblock](https://github.com/dblock).\n```\n",
|
246
|
-
"```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra period. - [@dblock](https://github.com/dblock).\n```\n",
|
247
|
-
"```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1): Unbalanced ( - [@dblock](https://github.com/dblock).\n```\n",
|
248
|
-
"```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1): Unbalanced ] - [@dblock](https://github.com/dblock).\n```\n"
|
249
|
-
]
|
250
|
-
end
|
251
115
|
end
|
252
116
|
end
|
253
117
|
end
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
describe 'with the Keep a Changelog format' do
|
258
|
-
let(:filename) { File.expand_path('fixtures/changelogs/keep_a_changelog.md', __dir__) }
|
259
|
-
let(:dangerfile) { testing_dangerfile }
|
260
|
-
let(:changelog) do
|
261
|
-
dangerfile.changelog.format = :keep_a_changelog
|
262
|
-
dangerfile.changelog.filename = filename
|
263
|
-
dangerfile.changelog
|
264
|
-
end
|
265
|
-
let(:status_report) { changelog.status_report }
|
266
|
-
|
267
|
-
describe 'in a PR' do
|
268
|
-
before do
|
269
|
-
changelog.env.request_source.pr_json = {
|
270
|
-
'number' => 123,
|
271
|
-
'title' => 'being dangerous',
|
272
|
-
'html_url' => 'https://github.com/dblock/danger-changelog/pull/123',
|
273
|
-
'user' => {
|
274
|
-
'login' => 'dblock'
|
275
|
-
}
|
276
|
-
}
|
277
|
-
end
|
278
118
|
|
279
|
-
context '
|
280
|
-
|
281
|
-
changelog.
|
119
|
+
context 'with a new CHANGELOG' do
|
120
|
+
before do
|
121
|
+
allow(changelog.git).to receive(:modified_files).and_return([])
|
122
|
+
allow(changelog.git).to receive(:added_files).and_return([changelog.filename])
|
282
123
|
end
|
283
124
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
it 'complains when no CHANGELOG can be found' do
|
291
|
-
expect(subject).to be false
|
292
|
-
expect(status_report[:errors]).to eq []
|
293
|
-
expect(status_report[:warnings]).to eq ["Unless you're refactoring existing code or improving documentation, please update #{filename}."]
|
294
|
-
expect(status_report[:markdowns].map(&:message)).to eq ["Here's an example of a #{filename} entry:\n\n```markdown\n* [#123](https://github.com/dblock/danger-changelog/pull/123): Being dangerous - [@dblock](https://github.com/dblock).\n```\n"]
|
295
|
-
end
|
125
|
+
it 'has no complaints' do
|
126
|
+
expect(subject).to be true
|
127
|
+
expect(status_report[:errors]).to eq []
|
128
|
+
expect(status_report[:warnings]).to eq []
|
129
|
+
expect(status_report[:markdowns]).to eq []
|
296
130
|
end
|
131
|
+
end
|
297
132
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
133
|
+
context 'with CHANGELOG changes' do
|
134
|
+
before do
|
135
|
+
allow(changelog.git).to receive(:modified_files).and_return([changelog.filename])
|
136
|
+
allow(changelog.git).to receive(:added_files).and_return([])
|
137
|
+
end
|
303
138
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
end
|
139
|
+
it 'has no complaints' do
|
140
|
+
expect(subject).to be true
|
141
|
+
expect(status_report[:errors]).to eq []
|
142
|
+
expect(status_report[:warnings]).to eq []
|
143
|
+
expect(status_report[:markdowns]).to eq []
|
310
144
|
end
|
311
145
|
end
|
312
146
|
end
|
data/spec/config_spec.rb
CHANGED
@@ -1,13 +1,21 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Danger::Changelog::Config do
|
4
4
|
describe 'placeholder_line' do
|
5
|
+
context 'an instance of a dangerfile' do
|
6
|
+
let(:dangerfile) { testing_dangerfile }
|
7
|
+
let(:changelog) { dangerfile.changelog }
|
8
|
+
|
9
|
+
it 'defaults placeholder_line' do
|
10
|
+
expect(changelog.placeholder_line).to eq "* Your contribution here.\n"
|
11
|
+
end
|
12
|
+
end
|
5
13
|
context 'when without markdown star' do
|
6
14
|
before do
|
7
15
|
Danger::Changelog.config.placeholder_line = "Nothing yet.\n"
|
8
16
|
end
|
9
17
|
|
10
|
-
it '
|
18
|
+
it 'adds missing star and saves configuration' do
|
11
19
|
expect(Danger::Changelog.config.placeholder_line).to eq "* Nothing yet.\n"
|
12
20
|
end
|
13
21
|
end
|
@@ -17,7 +25,7 @@ describe Danger::Changelog::Config do
|
|
17
25
|
Danger::Changelog.config.placeholder_line = '* Nothing yet.'
|
18
26
|
end
|
19
27
|
|
20
|
-
it '
|
28
|
+
it 'adds missing trailing newline and saves configuration' do
|
21
29
|
expect(Danger::Changelog.config.placeholder_line).to eq "* Nothing yet.\n"
|
22
30
|
end
|
23
31
|
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Danger::Changelog::ChangelogFile do
|
4
|
+
subject do
|
5
|
+
Danger::Changelog::ChangelogFile.new(filename).tap(&:parse)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'with the default format checker' do
|
9
|
+
context 'minimal example' do
|
10
|
+
let(:filename) { File.expand_path('fixtures/minimal.md', __dir__) }
|
11
|
+
it 'exists?' do
|
12
|
+
expect(subject.exists?).to be true
|
13
|
+
end
|
14
|
+
it 'bad_lines?' do
|
15
|
+
expect(subject.bad_lines).to eq []
|
16
|
+
expect(subject.bad_lines?).to be false
|
17
|
+
end
|
18
|
+
it 'is valid' do
|
19
|
+
expect(subject.bad_lines?).to be false
|
20
|
+
end
|
21
|
+
it 'has your contribution here' do
|
22
|
+
expect(subject.global_failures?).to be false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
context 'missing your contribution here' do
|
26
|
+
let(:filename) { File.expand_path('fixtures/missing_your_contribution_here.md', __dir__) }
|
27
|
+
it 'is valid' do
|
28
|
+
expect(subject.bad_lines?).to be false
|
29
|
+
end
|
30
|
+
it 'is missing your contribution here' do
|
31
|
+
expect(subject.global_failures?).to be true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
context 'does not exist' do
|
35
|
+
let(:filename) { 'whatever.md' }
|
36
|
+
it 'exists?' do
|
37
|
+
expect(subject.exists?).to be false
|
38
|
+
end
|
39
|
+
it 'bad_lines?' do
|
40
|
+
expect(subject.bad_lines).to be_empty
|
41
|
+
expect(subject.bad_lines?).to be false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
context 'with bad lines' do
|
45
|
+
let(:filename) { File.expand_path('fixtures/lines.md', __dir__) }
|
46
|
+
it 'is invalid' do
|
47
|
+
expect(subject.bad_lines?).to be true
|
48
|
+
end
|
49
|
+
it 'reports all bad lines' do
|
50
|
+
expect(subject.bad_lines).to eq [
|
51
|
+
["Missing star - [@dblock](https://github.com/dblock).\n", 'does not start with a star, does not include a pull request link'],
|
52
|
+
["* [#1](https://github.com/dblock/danger-changelog/pull/1) - Not a colon - [@dblock](https://github.com/dblock).\n"],
|
53
|
+
["* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)\n", 'is missing a period at the end of the line'],
|
54
|
+
["# [#1](https://github.com/dblock/danger-changelog/pull/1): Hash instead of star - [@dblock](https://github.com/dblock).\n", 'does not start with a star'],
|
55
|
+
["* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra period. - [@dblock](https://github.com/dblock).\n", 'has an extra period or comma at the end of the description'],
|
56
|
+
["* [#1](https://github.com/dblock/danger-changelog/pull/1): Unbalanced ( - [@dblock](https://github.com/dblock).\n", 'too many parenthesis'],
|
57
|
+
["* [#1](https://github.com/dblock/danger-changelog/pull/1): Unbalanced ] - [@dblock](https://github.com/dblock).\n", 'too many parenthesis']
|
58
|
+
]
|
59
|
+
end
|
60
|
+
it 'has your contribution here' do
|
61
|
+
expect(subject.global_failures?).to be false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
context 'with a line that has an extra trailing space' do
|
65
|
+
let(:filename) { File.expand_path('fixtures/extra_trailing_space.md', __dir__) }
|
66
|
+
it 'is invalid' do
|
67
|
+
expect(subject.bad_lines?).to be true
|
68
|
+
end
|
69
|
+
it 'reports all bad lines' do
|
70
|
+
expect(subject.bad_lines).to eq [
|
71
|
+
["* [#1](https://github.com/dblock/danger-changelog/pull/1): Extra trailing space - [@dblock](https://github.com/dblock). \n", 'has an extra trailing space, is missing a period at the end of the line']
|
72
|
+
]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
context 'with bad dates' do
|
76
|
+
let(:filename) { File.expand_path('fixtures/dates.md', __dir__) }
|
77
|
+
it 'is invalid' do
|
78
|
+
expect(subject.bad_lines?).to be true
|
79
|
+
end
|
80
|
+
it 'reports all bad dates' do
|
81
|
+
expect(subject.bad_lines).to eq [
|
82
|
+
["### 1.2.3 (1/2/2018)\n"],
|
83
|
+
["### 1.2.3 (2018/13/1)\n"],
|
84
|
+
["### 1.2.3 (2018/13)\n"],
|
85
|
+
["### 1.2.3 (2018/1/1/3)\n"]
|
86
|
+
]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
context 'with bad semver' do
|
90
|
+
let(:filename) { File.expand_path('fixtures/semver.md', __dir__) }
|
91
|
+
it 'is invalid' do
|
92
|
+
expect(subject.bad_lines?).to be true
|
93
|
+
end
|
94
|
+
it 'reports all bad dates' do
|
95
|
+
expect(subject.bad_lines).to eq [
|
96
|
+
["### 0 (2018/1/1)\n"],
|
97
|
+
["### 0. (2018/1/1)\n"],
|
98
|
+
["### 0.1. (2018/1/1)\n"]
|
99
|
+
]
|
100
|
+
end
|
101
|
+
end
|
102
|
+
context 'with imbalanced parenthesis' do
|
103
|
+
let(:filename) { File.expand_path('fixtures/imbalanced.md', __dir__) }
|
104
|
+
it 'is invalid' do
|
105
|
+
expect(subject.bad_lines?).to be true
|
106
|
+
end
|
107
|
+
it 'reports all bad lines' do
|
108
|
+
expect(subject.bad_lines).to eq [
|
109
|
+
["### 0.0.0)\n"],
|
110
|
+
["### (0.0.1\n"],
|
111
|
+
["### 1.2.3 (2018/1/1\n"],
|
112
|
+
["### 0.1.0 2018/1/1)\n"],
|
113
|
+
["### 0 ((2018/1/1)\n"],
|
114
|
+
["### 0. [2018/1/1)\n"],
|
115
|
+
["### 0.1. (2018/1/1)]\n"]
|
116
|
+
]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
data/spec/{changelog_placeholder_line_spec.rb → intridea/changelog_placeholder_line_spec.rb}
RENAMED
@@ -1,9 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Danger::Changelog::ChangelogPlaceholderLine do
|
4
|
+
let(:config) { Danger::Changelog.config }
|
5
|
+
|
4
6
|
context 'with a custom placeholder line' do
|
5
7
|
before do
|
6
|
-
|
8
|
+
config.placeholder_line = "* Nothing yet here.\n"
|
7
9
|
end
|
8
10
|
|
9
11
|
context 'when line is equal to placeholder_line from config' do
|
@@ -19,7 +21,7 @@ describe Danger::Changelog::ChangelogPlaceholderLine do
|
|
19
21
|
|
20
22
|
context 'with a blank placeholder line' do
|
21
23
|
before do
|
22
|
-
|
24
|
+
config.placeholder_line = nil
|
23
25
|
end
|
24
26
|
|
25
27
|
context 'when line is not blank' do
|