changelog_jira 1.12.0
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 +7 -0
- data/README.md +233 -0
- data/Rakefile +39 -0
- data/bin/git-generate-changelog +4 -0
- data/bin/github_changelog_generator +4 -0
- data/lib/CHANGELOG.md +58 -0
- data/lib/github_changelog_generator.rb +41 -0
- data/lib/github_changelog_generator/fetcher.rb +221 -0
- data/lib/github_changelog_generator/generator/generator.rb +143 -0
- data/lib/github_changelog_generator/generator/generator_fetcher.rb +83 -0
- data/lib/github_changelog_generator/generator/generator_generation.rb +190 -0
- data/lib/github_changelog_generator/generator/generator_processor.rb +193 -0
- data/lib/github_changelog_generator/generator/generator_tags.rb +184 -0
- data/lib/github_changelog_generator/helper.rb +37 -0
- data/lib/github_changelog_generator/parser.rb +285 -0
- data/lib/github_changelog_generator/parser_file.rb +103 -0
- data/lib/github_changelog_generator/reader.rb +84 -0
- data/lib/github_changelog_generator/task.rb +67 -0
- data/lib/github_changelog_generator/version.rb +3 -0
- data/man/git-generate-changelog.1 +252 -0
- data/man/git-generate-changelog.html +262 -0
- data/man/git-generate-changelog.md +179 -0
- data/spec/files/angular.js.md +9395 -0
- data/spec/files/bundler.md +1911 -0
- data/spec/files/github-changelog-generator.md +305 -0
- data/spec/install-gem-in-bundler.gemfile +3 -0
- data/spec/spec_helper.rb +55 -0
- data/spec/unit/fetcher_spec.rb +59 -0
- data/spec/unit/generator/generator_processor_spec.rb +28 -0
- data/spec/unit/generator/generator_tags_spec.rb +243 -0
- data/spec/unit/parse_file_spec.rb +73 -0
- data/spec/unit/parser_spec.rb +60 -0
- data/spec/unit/reader_spec.rb +113 -0
- metadata +190 -0
@@ -0,0 +1,243 @@
|
|
1
|
+
describe GitHubChangelogGenerator::Generator do
|
2
|
+
def tag_mash_with_name(tag)
|
3
|
+
Hashie::Mash.new.tap { |mash_tag| mash_tag.name = tag }
|
4
|
+
end
|
5
|
+
|
6
|
+
def tags_mash_from_strings(tags_strings)
|
7
|
+
tags_strings.map do |tag|
|
8
|
+
tag_mash_with_name(tag)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#filter_between_tags" do
|
13
|
+
context "when between_tags nil" do
|
14
|
+
before do
|
15
|
+
@generator = GitHubChangelogGenerator::Generator.new(between_tags: nil)
|
16
|
+
end
|
17
|
+
|
18
|
+
subject do
|
19
|
+
@generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3)))
|
20
|
+
end
|
21
|
+
it { is_expected.to be_a(Array) }
|
22
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
23
|
+
end
|
24
|
+
context "when between_tags same as input array" do
|
25
|
+
before do
|
26
|
+
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3))
|
27
|
+
end
|
28
|
+
subject do
|
29
|
+
@generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3)))
|
30
|
+
end
|
31
|
+
it { is_expected.to be_a(Array) }
|
32
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when between_tags filled with correct values" do
|
36
|
+
before do
|
37
|
+
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2))
|
38
|
+
end
|
39
|
+
subject do
|
40
|
+
@generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3)))
|
41
|
+
end
|
42
|
+
it { is_expected.to be_a(Array) }
|
43
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2))) }
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when between_tags filled with invalid values" do
|
47
|
+
before do
|
48
|
+
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 q w))
|
49
|
+
end
|
50
|
+
|
51
|
+
subject do
|
52
|
+
@generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3)))
|
53
|
+
end
|
54
|
+
it { is_expected.to be_a(Array) }
|
55
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1))) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#get_filtered_tags" do
|
60
|
+
subject do
|
61
|
+
generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3 4 5)))
|
62
|
+
end
|
63
|
+
|
64
|
+
context "with excluded and between tags" do
|
65
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3), exclude_tags: %w(2)) }
|
66
|
+
it { is_expected.to be_a Array }
|
67
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1 3))) }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#filter_excluded_tags" do
|
72
|
+
subject { generator.filter_excluded_tags(tags_mash_from_strings(%w(1 2 3))) }
|
73
|
+
|
74
|
+
context "with matching string" do
|
75
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w(3)) }
|
76
|
+
it { is_expected.to be_a Array }
|
77
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2))) }
|
78
|
+
end
|
79
|
+
|
80
|
+
context "with non-matching string" do
|
81
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w(invalid tags)) }
|
82
|
+
it { is_expected.to be_a Array }
|
83
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
84
|
+
end
|
85
|
+
|
86
|
+
context "with matching regex" do
|
87
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: /[23]/) }
|
88
|
+
it { is_expected.to be_a Array }
|
89
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1))) }
|
90
|
+
end
|
91
|
+
|
92
|
+
context "with non-matching regex" do
|
93
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: /[abc]/) }
|
94
|
+
it { is_expected.to be_a Array }
|
95
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "#filter_excluded_tags_regex" do
|
100
|
+
subject { generator.filter_excluded_tags(tags_mash_from_strings(%w(1 2 3))) }
|
101
|
+
|
102
|
+
context "with matching regex" do
|
103
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[23]") }
|
104
|
+
it { is_expected.to be_a Array }
|
105
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1))) }
|
106
|
+
end
|
107
|
+
|
108
|
+
context "with non-matching regex" do
|
109
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[45]") }
|
110
|
+
it { is_expected.to be_a Array }
|
111
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "#filter_since_tag" do
|
116
|
+
context "with filled array" do
|
117
|
+
subject { generator.filter_since_tag(tags_mash_from_strings(%w(1 2 3))) }
|
118
|
+
|
119
|
+
context "with valid since tag" do
|
120
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") }
|
121
|
+
it { is_expected.to be_a Array }
|
122
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1))) }
|
123
|
+
end
|
124
|
+
|
125
|
+
context "with invalid since tag" do
|
126
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "Invalid tag") }
|
127
|
+
it { is_expected.to be_a Array }
|
128
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context "with empty array" do
|
133
|
+
subject { generator.filter_since_tag(tags_mash_from_strings(%w())) }
|
134
|
+
|
135
|
+
context "with valid since tag" do
|
136
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") }
|
137
|
+
it { is_expected.to be_a Array }
|
138
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w())) }
|
139
|
+
end
|
140
|
+
|
141
|
+
context "with invalid since tag" do
|
142
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "Invalid tag") }
|
143
|
+
it { is_expected.to be_a Array }
|
144
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w())) }
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe "#filter_due_tag" do
|
150
|
+
context "with filled array" do
|
151
|
+
subject { generator.filter_due_tag(tags_mash_from_strings(%w(1 2 3))) }
|
152
|
+
|
153
|
+
context "with valid due tag" do
|
154
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "2") }
|
155
|
+
it { is_expected.to be_a Array }
|
156
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(3))) }
|
157
|
+
end
|
158
|
+
|
159
|
+
context "with invalid due tag" do
|
160
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "Invalid tag") }
|
161
|
+
it { is_expected.to be_a Array }
|
162
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context "with empty array" do
|
167
|
+
subject { generator.filter_due_tag(tags_mash_from_strings(%w())) }
|
168
|
+
|
169
|
+
context "with valid due tag" do
|
170
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "2") }
|
171
|
+
it { is_expected.to be_a Array }
|
172
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w())) }
|
173
|
+
end
|
174
|
+
|
175
|
+
context "with invalid due tag" do
|
176
|
+
let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "Invalid tag") }
|
177
|
+
it { is_expected.to be_a Array }
|
178
|
+
it { is_expected.to match_array(tags_mash_from_strings(%w())) }
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe "#get_time_of_tag" do
|
184
|
+
current_time = Time.now
|
185
|
+
before(:all) { @generator = GitHubChangelogGenerator::Generator.new }
|
186
|
+
context "run with nil parameter" do
|
187
|
+
it "should raise ChangelogGeneratorError" do
|
188
|
+
expect { @generator.get_time_of_tag nil }.to raise_error(GitHubChangelogGenerator::ChangelogGeneratorError)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
context "fetch already filled tag" do
|
192
|
+
before { @generator.instance_variable_set :@tag_times_hash, "valid_tag" => current_time }
|
193
|
+
subject { @generator.get_time_of_tag tag_mash_with_name("valid_tag") }
|
194
|
+
it { is_expected.to be_a_kind_of(Time) }
|
195
|
+
it { is_expected.to eq(current_time) }
|
196
|
+
end
|
197
|
+
context "fetch not filled tag" do
|
198
|
+
before do
|
199
|
+
mock = double("fake fetcher")
|
200
|
+
allow(mock).to receive_messages(fetch_date_of_tag: current_time)
|
201
|
+
@generator.instance_variable_set :@fetcher, mock
|
202
|
+
end
|
203
|
+
subject do
|
204
|
+
of_tag = @generator.get_time_of_tag(tag_mash_with_name("valid_tag"))
|
205
|
+
of_tag
|
206
|
+
end
|
207
|
+
it { is_expected.to be_a_kind_of(Time) }
|
208
|
+
it { is_expected.to eq(current_time) }
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "#sort_tags_by_date" do
|
213
|
+
let(:time1) { Time.now }
|
214
|
+
let(:time2) { Time.now }
|
215
|
+
let(:time3) { Time.now }
|
216
|
+
|
217
|
+
before(:all) do
|
218
|
+
@generator = GitHubChangelogGenerator::Generator.new
|
219
|
+
end
|
220
|
+
|
221
|
+
before do
|
222
|
+
@generator.instance_variable_set(:@tag_times_hash, "valid_tag1" => time1,
|
223
|
+
"valid_tag2" => time2,
|
224
|
+
"valid_tag3" => time3)
|
225
|
+
end
|
226
|
+
|
227
|
+
subject do
|
228
|
+
@generator.sort_tags_by_date(tags)
|
229
|
+
end
|
230
|
+
context "sort unsorted tags" do
|
231
|
+
let(:tags) { tags_mash_from_strings %w(valid_tag1 valid_tag2 valid_tag3) }
|
232
|
+
|
233
|
+
it { is_expected.to be_a_kind_of(Array) }
|
234
|
+
it { is_expected.to match_array(tags.reverse!) }
|
235
|
+
end
|
236
|
+
context "sort sorted tags" do
|
237
|
+
let(:tags) { tags_mash_from_strings %w(valid_tag3 valid_tag2 valid_tag1) }
|
238
|
+
|
239
|
+
it { is_expected.to be_a_kind_of(Array) }
|
240
|
+
it { is_expected.to match_array(tags) }
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
describe GitHubChangelogGenerator::ParserFile do
|
2
|
+
describe ".github_changelog_generator" do
|
3
|
+
let(:options) { {} }
|
4
|
+
|
5
|
+
context "when the well-known default file does not exist" do
|
6
|
+
let(:parser) { GitHubChangelogGenerator::ParserFile.new(options) }
|
7
|
+
subject { parser.parse! }
|
8
|
+
it { is_expected.to be_nil }
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when file is empty" do
|
12
|
+
let(:parser) { GitHubChangelogGenerator::ParserFile.new(options, StringIO.new("")) }
|
13
|
+
|
14
|
+
it "does not change the options" do
|
15
|
+
expect { parser.parse! }.to_not change { options }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when file is incorrect" do
|
20
|
+
let(:options_before_change) { options.dup }
|
21
|
+
let(:file) { StringIO.new("unreleased_label=staging\nunreleased: false") }
|
22
|
+
let(:parser) do
|
23
|
+
GitHubChangelogGenerator::ParserFile.new(options, file)
|
24
|
+
end
|
25
|
+
it { expect { parser.parse! }.to raise_error(/line #2/) }
|
26
|
+
end
|
27
|
+
|
28
|
+
context "allows empty lines and comments with semi-colon or pound sign" do
|
29
|
+
let(:file) { StringIO.new("\n \n# Comment on first line\nunreleased_label=staging\n; Comment on third line\nunreleased=false") }
|
30
|
+
let(:parser) do
|
31
|
+
GitHubChangelogGenerator::ParserFile.new(options, file)
|
32
|
+
end
|
33
|
+
it { expect { parser.parse! }.not_to raise_error }
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when override default values" do
|
37
|
+
let(:default_options) { GitHubChangelogGenerator::Parser.default_options }
|
38
|
+
let(:options) { {}.merge(default_options) }
|
39
|
+
let(:options_before_change) { options.dup }
|
40
|
+
let(:file) { StringIO.new("unreleased_label=staging\nunreleased=false\nheader==== Changelog ===") }
|
41
|
+
let(:parser) { GitHubChangelogGenerator::ParserFile.new(options, file) }
|
42
|
+
|
43
|
+
it "changes the options" do
|
44
|
+
expect { parser.parse! }.to change { options }
|
45
|
+
.from(options_before_change)
|
46
|
+
.to(options_before_change.merge(unreleased_label: "staging",
|
47
|
+
unreleased: false,
|
48
|
+
header: "=== Changelog ==="))
|
49
|
+
end
|
50
|
+
|
51
|
+
context "turns exclude-labels into an Array", bug: '#327' do
|
52
|
+
let(:file) do
|
53
|
+
StringIO.new(<<EOF
|
54
|
+
exclude-labels=73a91042-da6f-11e5-9335-1040f38d7f90,7adf83b4-da6f-11e5-ae18-1040f38d7f90
|
55
|
+
header_label=# My changelog
|
56
|
+
EOF
|
57
|
+
)
|
58
|
+
end
|
59
|
+
it "reads exclude_labels into an Array" do
|
60
|
+
expect { parser.parse! }.to change { options[:exclude_labels] }
|
61
|
+
.from(default_options[:exclude_labels])
|
62
|
+
.to(["73a91042-da6f-11e5-9335-1040f38d7f90", "7adf83b4-da6f-11e5-ae18-1040f38d7f90"])
|
63
|
+
end
|
64
|
+
|
65
|
+
it "translates given header_label into the :header option" do
|
66
|
+
expect { parser.parse! }.to change { options[:header] }
|
67
|
+
.from(default_options[:header])
|
68
|
+
.to("# My changelog")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
describe GitHubChangelogGenerator::Parser do
|
2
|
+
describe ".user_project_from_remote" do
|
3
|
+
context "when remote is type 1" do
|
4
|
+
subject { GitHubChangelogGenerator::Parser.user_project_from_remote("origin https://github.com/skywinder/ActionSheetPicker-3.0 (fetch)") }
|
5
|
+
it { is_expected.to be_a(Array) }
|
6
|
+
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
7
|
+
end
|
8
|
+
context "when remote is type 2" do
|
9
|
+
subject { GitHubChangelogGenerator::Parser.user_project_from_remote("https://github.com/skywinder/ActionSheetPicker-3.0") }
|
10
|
+
it { is_expected.to be_a(Array) }
|
11
|
+
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
12
|
+
end
|
13
|
+
context "when remote is type 3" do
|
14
|
+
subject { GitHubChangelogGenerator::Parser.user_project_from_remote("https://github.com/skywinder/ActionSheetPicker-3.0") }
|
15
|
+
it { is_expected.to be_a(Array) }
|
16
|
+
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
17
|
+
end
|
18
|
+
context "when remote is type 4" do
|
19
|
+
subject { GitHubChangelogGenerator::Parser.user_project_from_remote("origin git@github.com:skywinder/ActionSheetPicker-3.0.git (fetch)") }
|
20
|
+
it { is_expected.to be_a(Array) }
|
21
|
+
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
22
|
+
end
|
23
|
+
context "when remote is invalid" do
|
24
|
+
subject { GitHubChangelogGenerator::Parser.user_project_from_remote("some invalid text") }
|
25
|
+
it { is_expected.to be_a(Array) }
|
26
|
+
it { is_expected.to match_array([nil, nil]) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
describe ".user_project_from_option" do
|
30
|
+
context "when option is invalid" do
|
31
|
+
it("should return nil") { expect(GitHubChangelogGenerator::Parser.user_project_from_option("blah", nil, nil)).to be_nil }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when option is valid" do
|
35
|
+
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", nil, nil) }
|
36
|
+
it { is_expected.to be_a(Array) }
|
37
|
+
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
38
|
+
end
|
39
|
+
context "when option nil" do
|
40
|
+
subject { GitHubChangelogGenerator::Parser.user_project_from_option(nil, nil, nil) }
|
41
|
+
it { is_expected.to be_a(Array) }
|
42
|
+
it { is_expected.to match_array([nil, nil]) }
|
43
|
+
end
|
44
|
+
context "when site is nil" do
|
45
|
+
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", nil, nil) }
|
46
|
+
it { is_expected.to be_a(Array) }
|
47
|
+
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
48
|
+
end
|
49
|
+
context "when site is valid" do
|
50
|
+
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", nil, "https://codeclimate.com") }
|
51
|
+
it { is_expected.to be_a(Array) }
|
52
|
+
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
53
|
+
end
|
54
|
+
context "when second arg is not nil" do
|
55
|
+
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", "blah", nil) }
|
56
|
+
it { is_expected.to be_a(Array) }
|
57
|
+
it { is_expected.to match_array([nil, nil]) }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Enrico Stahn <mail@enricostahn.com>
|
3
|
+
#
|
4
|
+
# Copyright 2014, Zanui, <engineering@zanui.com.au>
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
describe GitHubChangelogGenerator::Reader do
|
20
|
+
before(:all) do
|
21
|
+
@reader = GitHubChangelogGenerator::Reader.new
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#parse_heading" do
|
25
|
+
context "when heading is empty" do
|
26
|
+
subject { @reader.parse_heading("## ") }
|
27
|
+
it { is_expected.to be_a(Hash) }
|
28
|
+
it { is_expected.to include("version", "url", "date") }
|
29
|
+
it { is_expected.to include("version" => nil, "url" => nil, "date" => nil) }
|
30
|
+
# TODO: Doesn't work?
|
31
|
+
# it { is_expected.to have_all_string_keys }
|
32
|
+
end
|
33
|
+
context "when given version, url and date" do
|
34
|
+
subject { @reader.parse_heading("## [1.3.10](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.10) (2015-03-18)") }
|
35
|
+
it { is_expected.to include("version" => "1.3.10") }
|
36
|
+
it { is_expected.to include("url" => "https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.10") }
|
37
|
+
it { is_expected.to include("date" => "2015-03-18") }
|
38
|
+
end
|
39
|
+
context "when no url and date is provided" do
|
40
|
+
subject { @reader.parse_heading("## foobar") }
|
41
|
+
it { is_expected.to include("version" => "foobar", "url" => nil, "date" => nil) }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#parse" do
|
46
|
+
context "when file is empty" do
|
47
|
+
subject { @reader.parse("") }
|
48
|
+
it { is_expected.to be_an(Array) }
|
49
|
+
it { is_expected.to be_empty }
|
50
|
+
end
|
51
|
+
context "when file has only the header" do
|
52
|
+
subject { @reader.parse("# Change Log") }
|
53
|
+
it { is_expected.to be_an(Array) }
|
54
|
+
it { is_expected.to be_empty }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "example CHANGELOG files" do
|
59
|
+
subject { @reader.read(File.expand_path(File.join(File.dirname(__FILE__), "..", "files", self.class.description))) }
|
60
|
+
context "github-changelog-generator.md" do
|
61
|
+
it { is_expected.to be_an(Array) }
|
62
|
+
it { is_expected.not_to be_empty }
|
63
|
+
it { expect(subject.count).to eq(28) }
|
64
|
+
it { expect(subject.first).to include("version" => "1.3.10") }
|
65
|
+
it { expect(subject.first).to include("url" => "https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.10") }
|
66
|
+
it { expect(subject.first).to include("date" => "2015-03-18") }
|
67
|
+
it { expect(subject.first).to include("content") }
|
68
|
+
it "content should not be empty" do
|
69
|
+
expect(subject.first["content"]).not_to be_empty
|
70
|
+
end
|
71
|
+
end
|
72
|
+
context "bundler.md" do
|
73
|
+
it { is_expected.to be_an(Array) }
|
74
|
+
it { is_expected.not_to be_empty }
|
75
|
+
it { expect(subject.count).to eq(151) }
|
76
|
+
it { expect(subject.first).to include("version" => "1.9.1") }
|
77
|
+
it { expect(subject.first).to include("url" => nil) }
|
78
|
+
it { expect(subject.first).to include("date" => "2015-03-21") }
|
79
|
+
it { expect(subject.first).to include("content") }
|
80
|
+
it "content should not be empty" do
|
81
|
+
expect(subject.first["content"]).not_to be_empty
|
82
|
+
end
|
83
|
+
end
|
84
|
+
context "angular.js.md" do
|
85
|
+
it { is_expected.to be_an(Array) }
|
86
|
+
it { is_expected.not_to be_empty }
|
87
|
+
it do
|
88
|
+
pending("Implement heading_level for parser.")
|
89
|
+
expect(subject.count).to eq(134)
|
90
|
+
end
|
91
|
+
# it do
|
92
|
+
# pending('Implement heading_level for parser.')
|
93
|
+
# expect(subject.first).to include('version' => '1.4.0-beta.6 cookie-liberation')
|
94
|
+
# end
|
95
|
+
# it do
|
96
|
+
# pending('Implement heading_level for parser.')
|
97
|
+
# expect(subject.first).to include('url' => nil)
|
98
|
+
# end
|
99
|
+
# it do
|
100
|
+
# pending('Implement heading_level for parser.')
|
101
|
+
# expect(subject.first).to include('date' => '2015-03-17')
|
102
|
+
# end
|
103
|
+
# it do
|
104
|
+
# pending('Implement heading_level for parser.')
|
105
|
+
# expect(subject.first).to include('content')
|
106
|
+
# end
|
107
|
+
# it 'content should not be empty' do
|
108
|
+
# pending('Implement heading_level for parser.')
|
109
|
+
# expect(subject.first['content']).not_to be_empty
|
110
|
+
# end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|