github_changelog_generator 1.15.0.pre.rc → 1.15.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.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE +1 -1
  3. data/README.md +126 -51
  4. data/bin/git-generate-changelog +1 -1
  5. data/lib/github_changelog_generator.rb +10 -6
  6. data/lib/github_changelog_generator/generator/entry.rb +218 -0
  7. data/lib/github_changelog_generator/generator/generator.rb +96 -119
  8. data/lib/github_changelog_generator/generator/generator_fetcher.rb +140 -21
  9. data/lib/github_changelog_generator/generator/generator_processor.rb +40 -10
  10. data/lib/github_changelog_generator/generator/generator_tags.rb +10 -12
  11. data/lib/github_changelog_generator/generator/section.rb +104 -0
  12. data/lib/github_changelog_generator/octo_fetcher.rb +113 -23
  13. data/lib/github_changelog_generator/options.rb +35 -4
  14. data/lib/github_changelog_generator/parser.rb +88 -49
  15. data/lib/github_changelog_generator/parser_file.rb +6 -2
  16. data/lib/github_changelog_generator/task.rb +2 -3
  17. data/lib/github_changelog_generator/version.rb +1 -1
  18. data/man/git-generate-changelog.1 +125 -51
  19. data/man/git-generate-changelog.1.html +145 -89
  20. data/man/git-generate-changelog.html +19 -7
  21. data/man/git-generate-changelog.md +141 -86
  22. data/spec/files/github-changelog-generator.md +114 -114
  23. data/spec/{install-gem-in-bundler.gemfile → install_gem_in_bundler.gemfile} +2 -0
  24. data/spec/spec_helper.rb +1 -5
  25. data/spec/unit/generator/entry_spec.rb +760 -0
  26. data/spec/unit/generator/generator_processor_spec.rb +9 -2
  27. data/spec/unit/generator/generator_tags_spec.rb +5 -21
  28. data/spec/unit/octo_fetcher_spec.rb +204 -197
  29. data/spec/unit/options_spec.rb +24 -0
  30. data/spec/unit/parse_file_spec.rb +2 -2
  31. data/spec/unit/reader_spec.rb +4 -4
  32. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_commits/when_API_is_valid/returns_commits.json +1 -0
  33. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_commits_before/when_API_is_valid/returns_commits.json +1 -1
  34. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid.json +1 -1
  35. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_issue_with_proper_key/values.json +1 -1
  36. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_issues.json +1 -1
  37. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_issues_with_labels.json +1 -1
  38. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_pull_request_with_proper_key/values.json +1 -1
  39. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_pull_requests_with_labels.json +1 -1
  40. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_pull_requests/when_API_call_is_valid.json +1 -1
  41. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_pull_requests/when_API_call_is_valid/returns_correct_pull_request_keys.json +1 -1
  42. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_pull_requests/when_API_call_is_valid/returns_pull_requests.json +1 -1
  43. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_commit/when_API_call_is_valid.json +1 -1
  44. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_commit/when_API_call_is_valid/returns_commit.json +1 -1
  45. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_date_of_tag/when_API_call_is_valid.json +1 -1
  46. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_date_of_tag/when_API_call_is_valid/returns_date.json +1 -1
  47. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_events_async/when_API_call_is_valid.json +1 -1
  48. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_events_async/when_API_call_is_valid/populates_issues.json +1 -1
  49. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_API_call_is_valid.json +1 -1
  50. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_API_call_is_valid/should_return_tags.json +1 -1
  51. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_API_call_is_valid/should_return_tags_count.json +1 -1
  52. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_wrong_token_provided.json +1 -1
  53. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_wrong_token_provided/should_raise_Unauthorized_error.json +1 -1
  54. metadata +17 -17
  55. data/bin/ghclgen +0 -5
  56. data/lib/github_changelog_generator/generator/generator_generation.rb +0 -181
  57. data/spec/unit/generator/generator_generation_spec.rb +0 -73
@@ -2,7 +2,7 @@
2
2
 
3
3
  module GitHubChangelogGenerator
4
4
  describe Generator do
5
- let(:default_options) { GitHubChangelogGenerator::Parser.default_options }
5
+ let(:default_options) { GitHubChangelogGenerator::Parser.default_options.merge(verbose: false) }
6
6
  let(:options) { {} }
7
7
  let(:generator) { described_class.new(default_options.merge(options)) }
8
8
 
@@ -67,11 +67,18 @@ module GitHubChangelogGenerator
67
67
 
68
68
  it { is_expected.to eq(expected_issues) }
69
69
  end
70
+
71
+ context "with 'include_labels'" do
72
+ let(:options) { { add_issues_wo_labels: false, include_labels: %w[GOOD] } }
73
+ let(:expected_issues) { [good_issue] }
74
+
75
+ it { is_expected.to eq(expected_issues) }
76
+ end
70
77
  end
71
78
 
72
79
  context "when 'include_labels' is specified" do
73
80
  let(:options) { { include_labels: %w[GOOD] } }
74
- let(:expected_issues) { [good_issue] }
81
+ let(:expected_issues) { [good_issue, unlabeled_issue] }
75
82
 
76
83
  it { is_expected.to eq(expected_issues) }
77
84
  end
@@ -17,7 +17,7 @@ describe GitHubChangelogGenerator::Generator do
17
17
  let(:all_tags) { tags_from_strings(%w[8 7 6 5 4 3 2 1]) }
18
18
  let(:sorted_tags) { all_tags }
19
19
 
20
- let(:default_options) { GitHubChangelogGenerator::Parser.default_options }
20
+ let(:default_options) { GitHubChangelogGenerator::Parser.default_options.merge(verbose: false) }
21
21
  let(:options) { {} }
22
22
  let(:generator) { described_class.new(default_options.merge(options)) }
23
23
 
@@ -191,24 +191,16 @@ describe GitHubChangelogGenerator::Generator do
191
191
 
192
192
  context "with invalid since tag" do
193
193
  let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "Invalid tag") }
194
- it { is_expected.to be_a Array }
195
- it { is_expected.to match_array(tags_from_strings(%w[1 2 3])) }
194
+ it { expect { subject }.to raise_error(GitHubChangelogGenerator::ChangelogGeneratorError) }
196
195
  end
197
196
  end
198
197
 
199
198
  context "with empty array" do
200
199
  subject { generator.filter_since_tag(tags_from_strings(%w[])) }
201
200
 
202
- context "with valid since tag" do
203
- let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") }
204
- it { is_expected.to be_a Array }
205
- it { is_expected.to match_array(tags_from_strings(%w[])) }
206
- end
207
-
208
201
  context "with invalid since tag" do
209
202
  let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "Invalid tag") }
210
- it { is_expected.to be_a Array }
211
- it { is_expected.to match_array(tags_from_strings(%w[])) }
203
+ it { expect { subject }.to raise_error(GitHubChangelogGenerator::ChangelogGeneratorError) }
212
204
  end
213
205
  end
214
206
  end
@@ -225,24 +217,16 @@ describe GitHubChangelogGenerator::Generator do
225
217
 
226
218
  context "with invalid due tag" do
227
219
  let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "Invalid tag") }
228
- it { is_expected.to be_a Array }
229
- it { is_expected.to match_array(tags_from_strings(%w[1 2 3])) }
220
+ it { expect { subject }.to raise_error(GitHubChangelogGenerator::ChangelogGeneratorError) }
230
221
  end
231
222
  end
232
223
 
233
224
  context "with empty array" do
234
225
  subject { generator.filter_due_tag(tags_from_strings(%w[])) }
235
226
 
236
- context "with valid due tag" do
237
- let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "2") }
238
- it { is_expected.to be_a Array }
239
- it { is_expected.to match_array(tags_from_strings(%w[])) }
240
- end
241
-
242
227
  context "with invalid due tag" do
243
228
  let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "Invalid tag") }
244
- it { is_expected.to be_a Array }
245
- it { is_expected.to match_array(tags_from_strings(%w[])) }
229
+ it { expect { subject }.to raise_error(GitHubChangelogGenerator::ChangelogGeneratorError) }
246
230
  end
247
231
  end
248
232
  end
@@ -6,7 +6,7 @@ INVALID_TOKEN = "0000000000000000"
6
6
  describe GitHubChangelogGenerator::OctoFetcher do
7
7
  let(:options) do
8
8
  {
9
- user: "skywinder",
9
+ user: "github-changelog-generator",
10
10
  project: "changelog_test"
11
11
  }
12
12
  end
@@ -89,7 +89,7 @@ describe GitHubChangelogGenerator::OctoFetcher do
89
89
  context "when wrong token provided", :vcr do
90
90
  let(:options) do
91
91
  {
92
- user: "skywinder",
92
+ user: "github-changelog-generator",
93
93
  project: "changelog_test",
94
94
  token: INVALID_TOKEN
95
95
  }
@@ -102,39 +102,39 @@ describe GitHubChangelogGenerator::OctoFetcher do
102
102
 
103
103
  context "when API call is valid", :vcr do
104
104
  it "should return tags" do
105
- expected_tags = [{ "name" => "v0.0.3",
105
+ expected_tags = [{ "name" => "v0.0.3",
106
106
  "zipball_url" =>
107
107
  "https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.3",
108
108
  "tarball_url" =>
109
109
  "https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.3",
110
- "commit" =>
110
+ "commit" =>
111
111
  { "sha" => "a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90",
112
112
  "url" =>
113
113
  "https://api.github.com/repos/skywinder/changelog_test/commits/a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90" } },
114
- { "name" => "v0.0.2",
114
+ { "name" => "v0.0.2",
115
115
  "zipball_url" =>
116
116
  "https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.2",
117
117
  "tarball_url" =>
118
118
  "https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.2",
119
- "commit" =>
119
+ "commit" =>
120
120
  { "sha" => "9b35bb13dcd15b68e7bcbf10cde5eb937a54f710",
121
121
  "url" =>
122
122
  "https://api.github.com/repos/skywinder/changelog_test/commits/9b35bb13dcd15b68e7bcbf10cde5eb937a54f710" } },
123
- { "name" => "v0.0.1",
123
+ { "name" => "v0.0.1",
124
124
  "zipball_url" =>
125
125
  "https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.1",
126
126
  "tarball_url" =>
127
127
  "https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.1",
128
- "commit" =>
128
+ "commit" =>
129
129
  { "sha" => "4c2d6d1ed58bdb24b870dcb5d9f2ceed0283d69d",
130
130
  "url" =>
131
131
  "https://api.github.com/repos/skywinder/changelog_test/commits/4c2d6d1ed58bdb24b870dcb5d9f2ceed0283d69d" } },
132
- { "name" => "0.0.4",
132
+ { "name" => "0.0.4",
133
133
  "zipball_url" =>
134
134
  "https://api.github.com/repos/skywinder/changelog_test/zipball/0.0.4",
135
135
  "tarball_url" =>
136
136
  "https://api.github.com/repos/skywinder/changelog_test/tarball/0.0.4",
137
- "commit" =>
137
+ "commit" =>
138
138
  { "sha" => "ece0c3ab7142b21064b885061c55ede00ef6ce94",
139
139
  "url" =>
140
140
  "https://api.github.com/repos/skywinder/changelog_test/commits/ece0c3ab7142b21064b885061c55ede00ef6ce94" } }]
@@ -160,54 +160,54 @@ describe GitHubChangelogGenerator::OctoFetcher do
160
160
  it "returns issue with proper key/values" do
161
161
  issues, _pull_requests = fetcher.fetch_closed_issues_and_pr
162
162
 
163
- expected_issue = { "url" => "https://api.github.com/repos/skywinder/changelog_test/issues/14",
163
+ expected_issue = { "url" => "https://api.github.com/repos/skywinder/changelog_test/issues/14",
164
164
  "repository_url" => "https://api.github.com/repos/skywinder/changelog_test",
165
- "labels_url" =>
165
+ "labels_url" =>
166
166
  "https://api.github.com/repos/skywinder/changelog_test/issues/14/labels{/name}",
167
- "comments_url" =>
167
+ "comments_url" =>
168
168
  "https://api.github.com/repos/skywinder/changelog_test/issues/14/comments",
169
- "events_url" =>
169
+ "events_url" =>
170
170
  "https://api.github.com/repos/skywinder/changelog_test/issues/14/events",
171
- "html_url" => "https://github.com/skywinder/changelog_test/issues/14",
172
- "id" => 95_419_412,
173
- "number" => 14,
174
- "title" => "Issue closed from commit from PR",
175
- "user" =>
176
- { "login" => "skywinder",
177
- "id" => 3_356_474,
178
- "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3",
179
- "gravatar_id" => "",
180
- "url" => "https://api.github.com/users/skywinder",
181
- "html_url" => "https://github.com/skywinder",
182
- "followers_url" => "https://api.github.com/users/skywinder/followers",
183
- "following_url" =>
171
+ "html_url" => "https://github.com/skywinder/changelog_test/issues/14",
172
+ "id" => 95_419_412,
173
+ "number" => 14,
174
+ "title" => "Issue closed from commit from PR",
175
+ "user" =>
176
+ { "login" => "skywinder",
177
+ "id" => 3_356_474,
178
+ "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3",
179
+ "gravatar_id" => "",
180
+ "url" => "https://api.github.com/users/skywinder",
181
+ "html_url" => "https://github.com/skywinder",
182
+ "followers_url" => "https://api.github.com/users/skywinder/followers",
183
+ "following_url" =>
184
184
  "https://api.github.com/users/skywinder/following{/other_user}",
185
- "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}",
186
- "starred_url" =>
185
+ "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}",
186
+ "starred_url" =>
187
187
  "https://api.github.com/users/skywinder/starred{/owner}{/repo}",
188
- "subscriptions_url" => "https://api.github.com/users/skywinder/subscriptions",
189
- "organizations_url" => "https://api.github.com/users/skywinder/orgs",
190
- "repos_url" => "https://api.github.com/users/skywinder/repos",
191
- "events_url" => "https://api.github.com/users/skywinder/events{/privacy}",
188
+ "subscriptions_url" => "https://api.github.com/users/skywinder/subscriptions",
189
+ "organizations_url" => "https://api.github.com/users/skywinder/orgs",
190
+ "repos_url" => "https://api.github.com/users/skywinder/repos",
191
+ "events_url" => "https://api.github.com/users/skywinder/events{/privacy}",
192
192
  "received_events_url" =>
193
193
  "https://api.github.com/users/skywinder/received_events",
194
- "type" => "User",
195
- "site_admin" => false },
196
- "labels" => [],
197
- "state" => "closed",
198
- "locked" => false,
199
- "assignee" => nil,
194
+ "type" => "User",
195
+ "site_admin" => false },
196
+ "labels" => [],
197
+ "state" => "closed",
198
+ "locked" => false,
199
+ "assignee" => nil,
200
200
  "assignees" => [],
201
- "milestone" => nil,
202
- "comments" => 0,
203
- "created_at" => "2015-07-16T12:06:08Z",
204
- "updated_at" => "2015-07-16T12:21:42Z",
205
- "closed_at" => "2015-07-16T12:21:42Z",
206
- "body" => "" }
201
+ "milestone" => nil,
202
+ "comments" => 0,
203
+ "created_at" => "2015-07-16T12:06:08Z",
204
+ "updated_at" => "2015-07-16T12:21:42Z",
205
+ "closed_at" => "2015-07-16T12:21:42Z",
206
+ "body" => "" }
207
207
 
208
208
  # Convert times to Time
209
209
  expected_issue.each_pair do |k, v|
210
- expected_issue[k] = Time.parse(v) if v =~ /^2015-/
210
+ expected_issue[k] = Time.parse(v) if v.to_s =~ /^2015-/
211
211
  end
212
212
 
213
213
  expect(issues.first).to eq(expected_issue)
@@ -216,60 +216,60 @@ describe GitHubChangelogGenerator::OctoFetcher do
216
216
  it "returns pull request with proper key/values" do
217
217
  _issues, pull_requests = fetcher.fetch_closed_issues_and_pr
218
218
 
219
- expected_pr = { "url" => "https://api.github.com/repos/skywinder/changelog_test/issues/21",
219
+ expected_pr = { "url" => "https://api.github.com/repos/skywinder/changelog_test/issues/21",
220
220
  "repository_url" => "https://api.github.com/repos/skywinder/changelog_test",
221
- "labels_url" =>
221
+ "labels_url" =>
222
222
  "https://api.github.com/repos/skywinder/changelog_test/issues/21/labels{/name}",
223
- "comments_url" =>
223
+ "comments_url" =>
224
224
  "https://api.github.com/repos/skywinder/changelog_test/issues/21/comments",
225
- "events_url" =>
225
+ "events_url" =>
226
226
  "https://api.github.com/repos/skywinder/changelog_test/issues/21/events",
227
- "html_url" => "https://github.com/skywinder/changelog_test/pull/21",
228
- "id" => 124_925_759,
229
- "number" => 21,
230
- "title" => "Merged br (should appear in change log with #20)",
231
- "user" =>
232
- { "login" => "skywinder",
233
- "id" => 3_356_474,
234
- "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3",
235
- "gravatar_id" => "",
236
- "url" => "https://api.github.com/users/skywinder",
237
- "html_url" => "https://github.com/skywinder",
238
- "followers_url" => "https://api.github.com/users/skywinder/followers",
239
- "following_url" =>
227
+ "html_url" => "https://github.com/skywinder/changelog_test/pull/21",
228
+ "id" => 124_925_759,
229
+ "number" => 21,
230
+ "title" => "Merged br (should appear in change log with #20)",
231
+ "user" =>
232
+ { "login" => "skywinder",
233
+ "id" => 3_356_474,
234
+ "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3",
235
+ "gravatar_id" => "",
236
+ "url" => "https://api.github.com/users/skywinder",
237
+ "html_url" => "https://github.com/skywinder",
238
+ "followers_url" => "https://api.github.com/users/skywinder/followers",
239
+ "following_url" =>
240
240
  "https://api.github.com/users/skywinder/following{/other_user}",
241
- "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}",
242
- "starred_url" =>
241
+ "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}",
242
+ "starred_url" =>
243
243
  "https://api.github.com/users/skywinder/starred{/owner}{/repo}",
244
- "subscriptions_url" => "https://api.github.com/users/skywinder/subscriptions",
245
- "organizations_url" => "https://api.github.com/users/skywinder/orgs",
246
- "repos_url" => "https://api.github.com/users/skywinder/repos",
247
- "events_url" => "https://api.github.com/users/skywinder/events{/privacy}",
244
+ "subscriptions_url" => "https://api.github.com/users/skywinder/subscriptions",
245
+ "organizations_url" => "https://api.github.com/users/skywinder/orgs",
246
+ "repos_url" => "https://api.github.com/users/skywinder/repos",
247
+ "events_url" => "https://api.github.com/users/skywinder/events{/privacy}",
248
248
  "received_events_url" =>
249
249
  "https://api.github.com/users/skywinder/received_events",
250
- "type" => "User",
251
- "site_admin" => false },
252
- "labels" => [],
253
- "state" => "closed",
254
- "locked" => false,
255
- "assignee" => nil,
250
+ "type" => "User",
251
+ "site_admin" => false },
252
+ "labels" => [],
253
+ "state" => "closed",
254
+ "locked" => false,
255
+ "assignee" => nil,
256
256
  "assignees" => [],
257
- "milestone" => nil,
258
- "comments" => 0,
259
- "created_at" => "2016-01-05T09:24:08Z",
260
- "updated_at" => "2016-01-05T09:26:53Z",
261
- "closed_at" => "2016-01-05T09:24:27Z",
262
- "pull_request" =>
263
- { "url" => "https://api.github.com/repos/skywinder/changelog_test/pulls/21",
264
- "html_url" => "https://github.com/skywinder/changelog_test/pull/21",
265
- "diff_url" => "https://github.com/skywinder/changelog_test/pull/21.diff",
257
+ "milestone" => nil,
258
+ "comments" => 0,
259
+ "created_at" => "2016-01-05T09:24:08Z",
260
+ "updated_at" => "2016-01-05T09:26:53Z",
261
+ "closed_at" => "2016-01-05T09:24:27Z",
262
+ "pull_request" =>
263
+ { "url" => "https://api.github.com/repos/skywinder/changelog_test/pulls/21",
264
+ "html_url" => "https://github.com/skywinder/changelog_test/pull/21",
265
+ "diff_url" => "https://github.com/skywinder/changelog_test/pull/21.diff",
266
266
  "patch_url" => "https://github.com/skywinder/changelog_test/pull/21.patch" },
267
- "body" =>
267
+ "body" =>
268
268
  "to test https://github.com/skywinder/github-changelog-generator/pull/305\r\nshould appear in change log with #20" }
269
269
 
270
270
  # Convert times to Time
271
271
  expected_pr.each_pair do |k, v|
272
- expected_pr[k] = Time.parse(v) if v =~ /^2016-01/
272
+ expected_pr[k] = Time.parse(v) if v.to_s =~ /^2016-01/
273
273
  end
274
274
 
275
275
  expect(pull_requests.first).to eq(expected_pr)
@@ -308,51 +308,51 @@ describe GitHubChangelogGenerator::OctoFetcher do
308
308
  describe "#fetch_events_async" do
309
309
  context "when API call is valid", :vcr do
310
310
  it "populates issues" do
311
- issues = [{ "url" => "https://api.github.com/repos/skywinder/changelog_test/issues/14",
311
+ issues = [{ "url" => "https://api.github.com/repos/skywinder/changelog_test/issues/14",
312
312
  "repository_url" => "https://api.github.com/repos/skywinder/changelog_test",
313
- "labels_url" =>
313
+ "labels_url" =>
314
314
  "https://api.github.com/repos/skywinder/changelog_test/issues/14/labels{/name}",
315
- "comments_url" =>
315
+ "comments_url" =>
316
316
  "https://api.github.com/repos/skywinder/changelog_test/issues/14/comments",
317
- "events_url" =>
317
+ "events_url" =>
318
318
  "https://api.github.com/repos/skywinder/changelog_test/issues/14/events",
319
- "html_url" => "https://github.com/skywinder/changelog_test/issues/14",
320
- "id" => 95_419_412,
321
- "number" => 14,
322
- "title" => "Issue closed from commit from PR",
323
- "user" =>
324
- { "login" => "skywinder",
325
- "id" => 3_356_474,
326
- "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3",
327
- "gravatar_id" => "",
328
- "url" => "https://api.github.com/users/skywinder",
329
- "html_url" => "https://github.com/skywinder",
330
- "followers_url" => "https://api.github.com/users/skywinder/followers",
331
- "following_url" =>
319
+ "html_url" => "https://github.com/skywinder/changelog_test/issues/14",
320
+ "id" => 95_419_412,
321
+ "number" => 14,
322
+ "title" => "Issue closed from commit from PR",
323
+ "user" =>
324
+ { "login" => "skywinder",
325
+ "id" => 3_356_474,
326
+ "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3",
327
+ "gravatar_id" => "",
328
+ "url" => "https://api.github.com/users/skywinder",
329
+ "html_url" => "https://github.com/skywinder",
330
+ "followers_url" => "https://api.github.com/users/skywinder/followers",
331
+ "following_url" =>
332
332
  "https://api.github.com/users/skywinder/following{/other_user}",
333
- "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}",
334
- "starred_url" =>
333
+ "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}",
334
+ "starred_url" =>
335
335
  "https://api.github.com/users/skywinder/starred{/owner}{/repo}",
336
- "subscriptions_url" =>
336
+ "subscriptions_url" =>
337
337
  "https://api.github.com/users/skywinder/subscriptions",
338
- "organizations_url" => "https://api.github.com/users/skywinder/orgs",
339
- "repos_url" => "https://api.github.com/users/skywinder/repos",
340
- "events_url" => "https://api.github.com/users/skywinder/events{/privacy}",
338
+ "organizations_url" => "https://api.github.com/users/skywinder/orgs",
339
+ "repos_url" => "https://api.github.com/users/skywinder/repos",
340
+ "events_url" => "https://api.github.com/users/skywinder/events{/privacy}",
341
341
  "received_events_url" =>
342
342
  "https://api.github.com/users/skywinder/received_events",
343
- "type" => "User",
344
- "site_admin" => false },
345
- "labels" => [],
346
- "state" => "closed",
347
- "locked" => false,
348
- "assignee" => nil,
343
+ "type" => "User",
344
+ "site_admin" => false },
345
+ "labels" => [],
346
+ "state" => "closed",
347
+ "locked" => false,
348
+ "assignee" => nil,
349
349
  "assignees" => [],
350
- "milestone" => nil,
351
- "comments" => 0,
352
- "created_at" => "2015-07-16T12:06:08Z",
353
- "updated_at" => "2015-07-16T12:21:42Z",
354
- "closed_at" => "2015-07-16T12:21:42Z",
355
- "body" => "" }]
350
+ "milestone" => nil,
351
+ "comments" => 0,
352
+ "created_at" => "2015-07-16T12:06:08Z",
353
+ "updated_at" => "2015-07-16T12:21:42Z",
354
+ "closed_at" => "2015-07-16T12:21:42Z",
355
+ "body" => "" }]
356
356
 
357
357
  # Check that they are blank to begin with
358
358
  expect(issues.first["events"]).to be_nil
@@ -360,63 +360,63 @@ describe GitHubChangelogGenerator::OctoFetcher do
360
360
  fetcher.fetch_events_async(issues)
361
361
  issue_events = issues.first["events"]
362
362
 
363
- expected_events = [{ "id" => 357_462_189,
364
- "url" =>
363
+ expected_events = [{ "id" => 357_462_189,
364
+ "url" =>
365
365
  "https://api.github.com/repos/skywinder/changelog_test/issues/events/357462189",
366
- "actor" =>
367
- { "login" => "skywinder",
368
- "id" => 3_356_474,
369
- "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3",
370
- "gravatar_id" => "",
371
- "url" => "https://api.github.com/users/skywinder",
372
- "html_url" => "https://github.com/skywinder",
373
- "followers_url" => "https://api.github.com/users/skywinder/followers",
374
- "following_url" =>
366
+ "actor" =>
367
+ { "login" => "skywinder",
368
+ "id" => 3_356_474,
369
+ "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3",
370
+ "gravatar_id" => "",
371
+ "url" => "https://api.github.com/users/skywinder",
372
+ "html_url" => "https://github.com/skywinder",
373
+ "followers_url" => "https://api.github.com/users/skywinder/followers",
374
+ "following_url" =>
375
375
  "https://api.github.com/users/skywinder/following{/other_user}",
376
- "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}",
377
- "starred_url" =>
376
+ "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}",
377
+ "starred_url" =>
378
378
  "https://api.github.com/users/skywinder/starred{/owner}{/repo}",
379
- "subscriptions_url" =>
379
+ "subscriptions_url" =>
380
380
  "https://api.github.com/users/skywinder/subscriptions",
381
- "organizations_url" => "https://api.github.com/users/skywinder/orgs",
382
- "repos_url" => "https://api.github.com/users/skywinder/repos",
383
- "events_url" => "https://api.github.com/users/skywinder/events{/privacy}",
381
+ "organizations_url" => "https://api.github.com/users/skywinder/orgs",
382
+ "repos_url" => "https://api.github.com/users/skywinder/repos",
383
+ "events_url" => "https://api.github.com/users/skywinder/events{/privacy}",
384
384
  "received_events_url" =>
385
385
  "https://api.github.com/users/skywinder/received_events",
386
- "type" => "User",
387
- "site_admin" => false },
388
- "event" => "referenced",
389
- "commit_id" => "decfe840d1a1b86e0c28700de5362d3365a29555",
386
+ "type" => "User",
387
+ "site_admin" => false },
388
+ "event" => "referenced",
389
+ "commit_id" => "decfe840d1a1b86e0c28700de5362d3365a29555",
390
390
  "commit_url" =>
391
391
  "https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555",
392
392
  "created_at" => "2015-07-16T12:21:16Z" },
393
- { "id" => 357_462_542,
394
- "url" =>
393
+ { "id" => 357_462_542,
394
+ "url" =>
395
395
  "https://api.github.com/repos/skywinder/changelog_test/issues/events/357462542",
396
- "actor" =>
397
- { "login" => "skywinder",
398
- "id" => 3_356_474,
399
- "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3",
400
- "gravatar_id" => "",
401
- "url" => "https://api.github.com/users/skywinder",
402
- "html_url" => "https://github.com/skywinder",
403
- "followers_url" => "https://api.github.com/users/skywinder/followers",
404
- "following_url" =>
396
+ "actor" =>
397
+ { "login" => "skywinder",
398
+ "id" => 3_356_474,
399
+ "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3",
400
+ "gravatar_id" => "",
401
+ "url" => "https://api.github.com/users/skywinder",
402
+ "html_url" => "https://github.com/skywinder",
403
+ "followers_url" => "https://api.github.com/users/skywinder/followers",
404
+ "following_url" =>
405
405
  "https://api.github.com/users/skywinder/following{/other_user}",
406
- "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}",
407
- "starred_url" =>
406
+ "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}",
407
+ "starred_url" =>
408
408
  "https://api.github.com/users/skywinder/starred{/owner}{/repo}",
409
- "subscriptions_url" =>
409
+ "subscriptions_url" =>
410
410
  "https://api.github.com/users/skywinder/subscriptions",
411
- "organizations_url" => "https://api.github.com/users/skywinder/orgs",
412
- "repos_url" => "https://api.github.com/users/skywinder/repos",
413
- "events_url" => "https://api.github.com/users/skywinder/events{/privacy}",
411
+ "organizations_url" => "https://api.github.com/users/skywinder/orgs",
412
+ "repos_url" => "https://api.github.com/users/skywinder/repos",
413
+ "events_url" => "https://api.github.com/users/skywinder/events{/privacy}",
414
414
  "received_events_url" =>
415
415
  "https://api.github.com/users/skywinder/received_events",
416
- "type" => "User",
417
- "site_admin" => false },
418
- "event" => "closed",
419
- "commit_id" => "decfe840d1a1b86e0c28700de5362d3365a29555",
416
+ "type" => "User",
417
+ "site_admin" => false },
418
+ "event" => "closed",
419
+ "commit_id" => "decfe840d1a1b86e0c28700de5362d3365a29555",
420
420
  "commit_url" =>
421
421
  "https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555",
422
422
  "created_at" => "2015-07-16T12:21:42Z" }]
@@ -424,7 +424,7 @@ describe GitHubChangelogGenerator::OctoFetcher do
424
424
  # Convert times to Time
425
425
  expected_events.map! do |event|
426
426
  event.each_pair do |k, v|
427
- event[k] = Time.parse(v) if v =~ /^201[56]-/
427
+ event[k] = Time.parse(v) if v.to_s =~ /^201[56]-/
428
428
  end
429
429
  end
430
430
 
@@ -436,17 +436,21 @@ describe GitHubChangelogGenerator::OctoFetcher do
436
436
  describe "#fetch_date_of_tag" do
437
437
  context "when API call is valid", :vcr do
438
438
  it "returns date" do
439
- tag = { "name" => "v0.0.3",
439
+ tag = { "name" => "v0.0.3",
440
440
  "zipball_url" =>
441
441
  "https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.3",
442
442
  "tarball_url" =>
443
443
  "https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.3",
444
- "commit" =>
444
+ "commit" =>
445
445
  { "sha" => "a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90",
446
446
  "url" =>
447
447
  "https://api.github.com/repos/skywinder/changelog_test/commits/a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90" } }
448
448
 
449
- dt = fetcher.fetch_date_of_tag(tag)
449
+ skywinder = GitHubChangelogGenerator::OctoFetcher.new(
450
+ user: "skywinder",
451
+ project: "changelog_test"
452
+ )
453
+ dt = skywinder.fetch_date_of_tag(tag)
450
454
  expect(dt).to eq(Time.parse("2015-03-04 19:01:48 UTC"))
451
455
  end
452
456
  end
@@ -469,36 +473,36 @@ describe GitHubChangelogGenerator::OctoFetcher do
469
473
  describe "#fetch_commit" do
470
474
  context "when API call is valid", :vcr do
471
475
  it "returns commit" do
472
- event = { "id" => 357_462_189,
473
- "url" =>
476
+ event = { "id" => 357_462_189,
477
+ "url" =>
474
478
  "https://api.github.com/repos/skywinder/changelog_test/issues/events/357462189",
475
- "actor" =>
476
- { "login" => "skywinder",
477
- "id" => 3_356_474,
478
- "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3",
479
- "gravatar_id" => "",
480
- "url" => "https://api.github.com/users/skywinder",
481
- "html_url" => "https://github.com/skywinder",
482
- "followers_url" => "https://api.github.com/users/skywinder/followers",
483
- "following_url" =>
479
+ "actor" =>
480
+ { "login" => "github-changelog-generator",
481
+ "id" => 3_356_474,
482
+ "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3",
483
+ "gravatar_id" => "",
484
+ "url" => "https://api.github.com/users/skywinder",
485
+ "html_url" => "https://github.com/skywinder",
486
+ "followers_url" => "https://api.github.com/users/skywinder/followers",
487
+ "following_url" =>
484
488
  "https://api.github.com/users/skywinder/following{/other_user}",
485
- "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}",
486
- "starred_url" =>
489
+ "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}",
490
+ "starred_url" =>
487
491
  "https://api.github.com/users/skywinder/starred{/owner}{/repo}",
488
- "subscriptions_url" => "https://api.github.com/users/skywinder/subscriptions",
489
- "organizations_url" => "https://api.github.com/users/skywinder/orgs",
490
- "repos_url" => "https://api.github.com/users/skywinder/repos",
491
- "events_url" => "https://api.github.com/users/skywinder/events{/privacy}",
492
+ "subscriptions_url" => "https://api.github.com/users/skywinder/subscriptions",
493
+ "organizations_url" => "https://api.github.com/users/skywinder/orgs",
494
+ "repos_url" => "https://api.github.com/users/skywinder/repos",
495
+ "events_url" => "https://api.github.com/users/skywinder/events{/privacy}",
492
496
  "received_events_url" =>
493
497
  "https://api.github.com/users/skywinder/received_events",
494
- "type" => "User",
495
- "site_admin" => false },
496
- "event" => "referenced",
497
- "commit_id" => "decfe840d1a1b86e0c28700de5362d3365a29555",
498
+ "type" => "User",
499
+ "site_admin" => false },
500
+ "event" => "referenced",
501
+ "commit_id" => "decfe840d1a1b86e0c28700de5362d3365a29555",
498
502
  "commit_url" =>
499
503
  "https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555",
500
504
  "created_at" => "2015-07-16T12:21:16Z" }
501
- commit = fetcher.fetch_commit(event)
505
+ commit = fetcher.fetch_commit(event["commit_id"])
502
506
 
503
507
  expectations = [
504
508
  %w[sha decfe840d1a1b86e0c28700de5362d3365a29555],
@@ -508,9 +512,9 @@ describe GitHubChangelogGenerator::OctoFetcher do
508
512
  ["html_url",
509
513
  "https://github.com/skywinder/changelog_test/commit/decfe840d1a1b86e0c28700de5362d3365a29555"],
510
514
  ["author",
511
- { "login" => "skywinder", "id" => 3_356_474, "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3", "gravatar_id" => "", "url" => "https://api.github.com/users/skywinder", "html_url" => "https://github.com/skywinder", "followers_url" => "https://api.github.com/users/skywinder/followers", "following_url" => "https://api.github.com/users/skywinder/following{/other_user}", "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}", "starred_url" => "https://api.github.com/users/skywinder/starred{/owner}{/repo}", "subscriptions_url" => "https://api.github.com/users/skywinder/subscriptions", "organizations_url" => "https://api.github.com/users/skywinder/orgs", "repos_url" => "https://api.github.com/users/skywinder/repos", "events_url" => "https://api.github.com/users/skywinder/events{/privacy}", "received_events_url" => "https://api.github.com/users/skywinder/received_events", "type" => "User", "site_admin" => false }],
515
+ { "login" => "skywinder", "id" => 3_356_474, "avatar_url" => "https://avatars2.githubusercontent.com/u/3356474?v=4", "gravatar_id" => "", "url" => "https://api.github.com/users/skywinder", "html_url" => "https://github.com/skywinder", "followers_url" => "https://api.github.com/users/skywinder/followers", "following_url" => "https://api.github.com/users/skywinder/following{/other_user}", "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}", "starred_url" => "https://api.github.com/users/skywinder/starred{/owner}{/repo}", "subscriptions_url" => "https://api.github.com/users/skywinder/subscriptions", "organizations_url" => "https://api.github.com/users/skywinder/orgs", "repos_url" => "https://api.github.com/users/skywinder/repos", "events_url" => "https://api.github.com/users/skywinder/events{/privacy}", "received_events_url" => "https://api.github.com/users/skywinder/received_events", "type" => "User", "site_admin" => false }],
512
516
  ["committer",
513
- { "login" => "skywinder", "id" => 3_356_474, "avatar_url" => "https://avatars.githubusercontent.com/u/3356474?v=3", "gravatar_id" => "", "url" => "https://api.github.com/users/skywinder", "html_url" => "https://github.com/skywinder", "followers_url" => "https://api.github.com/users/skywinder/followers", "following_url" => "https://api.github.com/users/skywinder/following{/other_user}", "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}", "starred_url" => "https://api.github.com/users/skywinder/starred{/owner}{/repo}", "subscriptions_url" => "https://api.github.com/users/skywinder/subscriptions", "organizations_url" => "https://api.github.com/users/skywinder/orgs", "repos_url" => "https://api.github.com/users/skywinder/repos", "events_url" => "https://api.github.com/users/skywinder/events{/privacy}", "received_events_url" => "https://api.github.com/users/skywinder/received_events", "type" => "User", "site_admin" => false }],
517
+ { "login" => "skywinder", "id" => 3_356_474, "avatar_url" => "https://avatars2.githubusercontent.com/u/3356474?v=4", "gravatar_id" => "", "url" => "https://api.github.com/users/skywinder", "html_url" => "https://github.com/skywinder", "followers_url" => "https://api.github.com/users/skywinder/followers", "following_url" => "https://api.github.com/users/skywinder/following{/other_user}", "gists_url" => "https://api.github.com/users/skywinder/gists{/gist_id}", "starred_url" => "https://api.github.com/users/skywinder/starred{/owner}{/repo}", "subscriptions_url" => "https://api.github.com/users/skywinder/subscriptions", "organizations_url" => "https://api.github.com/users/skywinder/orgs", "repos_url" => "https://api.github.com/users/skywinder/repos", "events_url" => "https://api.github.com/users/skywinder/events{/privacy}", "received_events_url" => "https://api.github.com/users/skywinder/received_events", "type" => "User", "site_admin" => false }],
514
518
  ["parents",
515
519
  [{ "sha" => "7ec095e5e3caceacedabf44d0b9b10da17c92e51",
516
520
  "url" =>
@@ -520,19 +524,22 @@ describe GitHubChangelogGenerator::OctoFetcher do
520
524
  "https://github.com/skywinder/changelog_test/commit/7ec095e5e3caceacedabf44d0b9b10da17c92e51" }]]
521
525
  ]
522
526
 
523
- expectations.each do |property, val|
524
- expect(commit[property]).to eq(val)
527
+ expectations.each do |property, value|
528
+ case value
529
+ when String, Array
530
+ expect(commit[property]).to eq(value)
531
+ when Hash
532
+ expect(commit[property]).to include(value)
533
+ end
525
534
  end
526
535
  end
527
536
  end
528
537
  end
529
538
 
530
- describe "#commits_before" do
539
+ describe "#commits" do
531
540
  context "when API is valid", :vcr do
532
- let(:start_time) { Time.parse("Wed Mar 4 18:47:17 2015 +0200") }
533
-
534
541
  subject do
535
- fetcher.commits_before(start_time)
542
+ fetcher.commits
536
543
  end
537
544
 
538
545
  it "returns commits" do