fixing rubocop and removing original fetcher
This commit is contained in:
committed by
Olle Jonsson
parent
0e948fb125
commit
ef9867c122
@@ -38,16 +38,15 @@ end
|
||||
require "github_changelog_generator"
|
||||
require "github_changelog_generator/task"
|
||||
|
||||
|
||||
VCR.configure do |c|
|
||||
c.allow_http_connections_when_no_cassette = true
|
||||
c.cassette_library_dir = 'spec/vcr'
|
||||
c.cassette_library_dir = "spec/vcr"
|
||||
c.ignore_localhost = true
|
||||
c.default_cassette_options = {
|
||||
:record => :new_episodes,
|
||||
:serialize_with => :json,
|
||||
:preserve_exact_body_bytes => true,
|
||||
:decode_compressed_response => true,
|
||||
record: :new_episodes,
|
||||
serialize_with: :json,
|
||||
preserve_exact_body_bytes: true,
|
||||
decode_compressed_response: true
|
||||
}
|
||||
|
||||
c.hook_into :webmock, :faraday
|
||||
@@ -74,6 +73,4 @@ RSpec.configure do |config|
|
||||
Kernel.srand config.seed
|
||||
|
||||
config.extend VCR::RSpec::Macros
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -1,231 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
VALID_TOKEN = "0123456789abcdef"
|
||||
INVALID_TOKEN = "0000000000000000"
|
||||
|
||||
describe GitHubChangelogGenerator::Fetcher do
|
||||
let(:options) do
|
||||
{
|
||||
:user => "skywinder",
|
||||
:project => "changelog_test",
|
||||
}
|
||||
end
|
||||
|
||||
let(:fetcher) { GitHubChangelogGenerator::Fetcher.new(options) }
|
||||
|
||||
|
||||
describe "#fetch_github_token" do
|
||||
token = GitHubChangelogGenerator::Fetcher::CHANGELOG_GITHUB_TOKEN
|
||||
context "when token in ENV exist" do
|
||||
before { stub_const("ENV", ENV.to_hash.merge(token => VALID_TOKEN)) }
|
||||
subject { fetcher.fetch_github_token }
|
||||
it { is_expected.to eq(VALID_TOKEN) }
|
||||
end
|
||||
|
||||
context "when token in ENV is nil" do
|
||||
before { stub_const("ENV", ENV.to_hash.merge(token => nil)) }
|
||||
subject { fetcher.fetch_github_token }
|
||||
it { is_expected.to be_nil }
|
||||
end
|
||||
|
||||
context "when token in options and ENV is nil" do
|
||||
let(:options) { { :token => VALID_TOKEN } }
|
||||
|
||||
before do
|
||||
stub_const("ENV", ENV.to_hash.merge(token => nil))
|
||||
end
|
||||
|
||||
subject { fetcher.fetch_github_token }
|
||||
it { is_expected.to eq(VALID_TOKEN) }
|
||||
end
|
||||
|
||||
context "when token in options and ENV specified" do
|
||||
let(:options) { { :token => VALID_TOKEN } }
|
||||
|
||||
before do
|
||||
stub_const("ENV", ENV.to_hash.merge(token => "no_matter_what"))
|
||||
end
|
||||
|
||||
subject { fetcher.fetch_github_token }
|
||||
it { is_expected.to eq(VALID_TOKEN) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#get_all_tags" do
|
||||
context "when github_fetch_tags returns tags" do
|
||||
it "returns tags" do
|
||||
mock_tags = ['tag']
|
||||
allow(fetcher).to receive(:github_fetch_tags).and_return(mock_tags)
|
||||
expect(fetcher.get_all_tags).to eq(mock_tags)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#github_fetch_tags" do
|
||||
context "when wrong token provided" do
|
||||
use_vcr_cassette
|
||||
|
||||
let(:options) do
|
||||
{
|
||||
:user => "skywinder",
|
||||
:project => "changelog_test",
|
||||
:token => INVALID_TOKEN
|
||||
}
|
||||
end
|
||||
|
||||
it "should raise Unauthorized error" do
|
||||
expect { fetcher.github_fetch_tags }.to raise_error Github::Error::Unauthorized
|
||||
end
|
||||
end
|
||||
|
||||
context "when API call is valid" do
|
||||
use_vcr_cassette
|
||||
|
||||
it "should return tags" do
|
||||
expected_tags = [{"name"=>"v0.0.3", "zipball_url"=>"https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.3", "tarball_url"=>"https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.3", "commit"=>{"sha"=>"a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90", "url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90"}}, {"name"=>"v0.0.2", "zipball_url"=>"https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.2", "tarball_url"=>"https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.2", "commit"=>{"sha"=>"9b35bb13dcd15b68e7bcbf10cde5eb937a54f710", "url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/9b35bb13dcd15b68e7bcbf10cde5eb937a54f710"}}, {"name"=>"v0.0.1", "zipball_url"=>"https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.1", "tarball_url"=>"https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.1", "commit"=>{"sha"=>"4c2d6d1ed58bdb24b870dcb5d9f2ceed0283d69d", "url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/4c2d6d1ed58bdb24b870dcb5d9f2ceed0283d69d"}}, {"name"=>"0.0.4", "zipball_url"=>"https://api.github.com/repos/skywinder/changelog_test/zipball/0.0.4", "tarball_url"=>"https://api.github.com/repos/skywinder/changelog_test/tarball/0.0.4", "commit"=>{"sha"=>"ece0c3ab7142b21064b885061c55ede00ef6ce94", "url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/ece0c3ab7142b21064b885061c55ede00ef6ce94"}}]
|
||||
|
||||
expect(fetcher.github_fetch_tags).to eq(expected_tags)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "#fetch_closed_issues_and_pr" do
|
||||
context "when API call is valid" do
|
||||
use_vcr_cassette
|
||||
|
||||
|
||||
it "returns issues" do
|
||||
issues, pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
expect(issues.size).to eq(7)
|
||||
expect(pull_requests.size).to eq(14)
|
||||
end
|
||||
|
||||
it "returns issue with proper key/values" do
|
||||
issues, pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
expected_issue = {"url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14", "repository_url"=>"https://api.github.com/repos/skywinder/changelog_test", "labels_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14/labels{/name}", "comments_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14/comments", "events_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14/events", "html_url"=>"https://github.com/skywinder/changelog_test/issues/14", "id"=>95419412, "number"=>14, "title"=>"Issue closed from commit from PR", "user"=>{"login"=>"skywinder", "id"=>3356474, "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}, "labels"=>[], "state"=>"closed", "locked"=>false, "assignee"=>nil, "milestone"=>nil, "comments"=>0, "created_at"=>"2015-07-16T12:06:08Z", "updated_at"=>"2015-07-16T12:21:42Z", "closed_at"=>"2015-07-16T12:21:42Z", "body"=>""}
|
||||
expect(issues.first).to eq(expected_issue)
|
||||
end
|
||||
|
||||
it "returns pull request with proper key/values" do
|
||||
issues, pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
expected_pr = {"url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/21", "repository_url"=>"https://api.github.com/repos/skywinder/changelog_test", "labels_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/21/labels{/name}", "comments_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/21/comments", "events_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/21/events", "html_url"=>"https://github.com/skywinder/changelog_test/pull/21", "id"=>124925759, "number"=>21, "title"=>"Merged br (should appear in change log with #20)", "user"=>{"login"=>"skywinder", "id"=>3356474, "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}, "labels"=>[], "state"=>"closed", "locked"=>false, "assignee"=>nil, "milestone"=>nil, "comments"=>0, "created_at"=>"2016-01-05T09:24:08Z", "updated_at"=>"2016-01-05T09:26:53Z", "closed_at"=>"2016-01-05T09:24:27Z", "pull_request"=>{"url"=>"https://api.github.com/repos/skywinder/changelog_test/pulls/21", "html_url"=>"https://github.com/skywinder/changelog_test/pull/21", "diff_url"=>"https://github.com/skywinder/changelog_test/pull/21.diff", "patch_url"=>"https://github.com/skywinder/changelog_test/pull/21.patch"}, "body"=>"to test https://github.com/skywinder/github-changelog-generator/pull/305\r\nshould appear in change log with #20"}
|
||||
expect(pull_requests.first).to eq(expected_pr)
|
||||
end
|
||||
|
||||
|
||||
it "returns issues with labels" do
|
||||
issues, pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
expected = [[], [], ["Bug"], [], ["enhancement"], ["some label"], []]
|
||||
expect(issues.map{|i| i.labels.map(&:name) }).to eq(expected)
|
||||
end
|
||||
|
||||
it "returns pull_requests with labels" do
|
||||
issues, pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
expected = [[], [], [], [], [], ["enhancement"], [], [], ["invalid"], [], [], [], [], ["invalid"]]
|
||||
expect(pull_requests.map{|i| i.labels.map(&:name) }).to eq(expected)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#fetch_closed_pull_requests" do
|
||||
context "when API call is valid" do
|
||||
use_vcr_cassette
|
||||
|
||||
it "returns pull requests" do
|
||||
pull_requests = fetcher.fetch_closed_pull_requests
|
||||
expect(pull_requests.size).to eq(14)
|
||||
end
|
||||
|
||||
it "returns correct pull request keys" do
|
||||
pull_requests = fetcher.fetch_closed_pull_requests
|
||||
|
||||
pr = pull_requests.first
|
||||
expect(pr.keys).to eq(["url", "id", "html_url", "diff_url", "patch_url", "issue_url", "number", "state", "locked", "title", "user", "body", "created_at", "updated_at", "closed_at", "merged_at", "merge_commit_sha", "assignee", "milestone", "commits_url", "review_comments_url", "review_comment_url", "comments_url", "statuses_url", "head", "base", "_links"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "#fetch_events_async" do
|
||||
context "when API call is valid" do
|
||||
use_vcr_cassette
|
||||
|
||||
it "populates issues" do
|
||||
issues = [{"url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14", "repository_url"=>"https://api.github.com/repos/skywinder/changelog_test", "labels_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14/labels{/name}", "comments_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14/comments", "events_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14/events", "html_url"=>"https://github.com/skywinder/changelog_test/issues/14", "id"=>95419412, "number"=>14, "title"=>"Issue closed from commit from PR", "user"=>{"login"=>"skywinder", "id"=>3356474, "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}, "labels"=>[], "state"=>"closed", "locked"=>false, "assignee"=>nil, "milestone"=>nil, "comments"=>0, "created_at"=>"2015-07-16T12:06:08Z", "updated_at"=>"2015-07-16T12:21:42Z", "closed_at"=>"2015-07-16T12:21:42Z", "body"=>""}]
|
||||
|
||||
# Check that they are blank to begin with
|
||||
expect(issues.first['events']).to be_nil
|
||||
|
||||
fetcher.fetch_events_async(issues)
|
||||
issue_events = issues.first['events']
|
||||
|
||||
expected_events = [{"id"=>357462189, "url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/events/357462189", "actor"=>{"login"=>"skywinder", "id"=>3356474, "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}, "event"=>"referenced", "commit_id"=>"decfe840d1a1b86e0c28700de5362d3365a29555", "commit_url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555", "created_at"=>"2015-07-16T12:21:16Z"}, {"id"=>357462542, "url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/events/357462542", "actor"=>{"login"=>"skywinder", "id"=>3356474, "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}, "event"=>"closed", "commit_id"=>"decfe840d1a1b86e0c28700de5362d3365a29555", "commit_url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555", "created_at"=>"2015-07-16T12:21:42Z"}]
|
||||
expect(issue_events).to eq(expected_events)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "#fetch_date_of_tag" do
|
||||
context "when API call is valid" do
|
||||
use_vcr_cassette
|
||||
|
||||
it "returns date" do
|
||||
tag = {"name"=>"v0.0.3", "zipball_url"=>"https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.3", "tarball_url"=>"https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.3", "commit"=>{"sha"=>"a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90", "url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90"}}
|
||||
dt = fetcher.fetch_date_of_tag(tag)
|
||||
expect(dt).to eq(Time.parse("2015-03-04 19:01:48 UTC"))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "#fetch_commit" do
|
||||
context "when API call is valid" do
|
||||
use_vcr_cassette
|
||||
|
||||
it "returns commit" do
|
||||
event = {"id"=>357462189, "url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/events/357462189", "actor"=>{"login"=>"skywinder", "id"=>3356474, "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}, "event"=>"referenced", "commit_id"=>"decfe840d1a1b86e0c28700de5362d3365a29555", "commit_url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555", "created_at"=>"2015-07-16T12:21:16Z"}
|
||||
commit = fetcher.fetch_commit(event)
|
||||
|
||||
expectations = [
|
||||
["sha", "decfe840d1a1b86e0c28700de5362d3365a29555"],
|
||||
["url",
|
||||
"https://api.github.com/repos/skywinder/changelog_test/git/commits/decfe840d1a1b86e0c28700de5362d3365a29555"],
|
||||
["html_url",
|
||||
"https://github.com/skywinder/changelog_test/commit/decfe840d1a1b86e0c28700de5362d3365a29555"],
|
||||
["author",
|
||||
{"name"=>"Petr Korolev",
|
||||
"email"=>"sky4winder@gmail.com",
|
||||
"date"=>"2015-07-16T12:11:01Z"}],
|
||||
["committer",
|
||||
{"name"=>"Petr Korolev",
|
||||
"email"=>"sky4winder@gmail.com",
|
||||
"date"=>"2015-07-16T12:11:01Z"}],
|
||||
["tree",
|
||||
{"sha"=>"0699c15258a7c2b2e157051fe19851d4f705cac8",
|
||||
"url"=>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/git/trees/0699c15258a7c2b2e157051fe19851d4f705cac8"}],
|
||||
["message", "fix #14"],
|
||||
["parents",
|
||||
[{"sha"=>"7ec095e5e3caceacedabf44d0b9b10da17c92e51",
|
||||
"url"=>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/git/commits/7ec095e5e3caceacedabf44d0b9b10da17c92e51",
|
||||
"html_url"=>
|
||||
"https://github.com/skywinder/changelog_test/commit/7ec095e5e3caceacedabf44d0b9b10da17c92e51"}]
|
||||
]
|
||||
]
|
||||
|
||||
expectations.each do |property, val|
|
||||
expect(commit.send(property)).to eq(val)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
@@ -2,10 +2,10 @@
|
||||
module GitHubChangelogGenerator
|
||||
describe Generator do
|
||||
context "#exclude_issues_by_labels" do
|
||||
let(:label) { { 'name' => "BAD" } }
|
||||
let(:issue) { { 'labels' => [label] } }
|
||||
let(:good_label) { { 'name' => "GOOD" } }
|
||||
let(:good_issue) { { 'labels' => [good_label] } }
|
||||
let(:label) { { "name" => "BAD" } }
|
||||
let(:issue) { { "labels" => [label] } }
|
||||
let(:good_label) { { "name" => "GOOD" } }
|
||||
let(:good_issue) { { "labels" => [good_label] } }
|
||||
let(:issues) { [issue, good_issue] }
|
||||
subject(:generator) { described_class.new(exclude_labels: %w(BAD BOO)) }
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
describe GitHubChangelogGenerator::Generator do
|
||||
def tag_mash_with_name(tag)
|
||||
Hashie::Mash.new.tap { |mash_tag| mash_tag.name = tag }
|
||||
def tag_with_name(tag)
|
||||
{}.tap { |mash_tag| mash_tag["name"] = tag }
|
||||
end
|
||||
|
||||
def tags_mash_from_strings(tags_strings)
|
||||
def tags_from_strings(tags_strings)
|
||||
tags_strings.map do |tag|
|
||||
tag_mash_with_name(tag)
|
||||
tag_with_name(tag)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,20 +17,20 @@ describe GitHubChangelogGenerator::Generator do
|
||||
end
|
||||
|
||||
subject do
|
||||
@generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3)))
|
||||
@generator.get_filtered_tags(tags_from_strings(%w(1 2 3)))
|
||||
end
|
||||
it { is_expected.to be_a(Array) }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) }
|
||||
end
|
||||
context "when between_tags same as input array" do
|
||||
before do
|
||||
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3))
|
||||
end
|
||||
subject do
|
||||
@generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3)))
|
||||
@generator.get_filtered_tags(tags_from_strings(%w(1 2 3)))
|
||||
end
|
||||
it { is_expected.to be_a(Array) }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) }
|
||||
end
|
||||
|
||||
context "when between_tags filled with correct values" do
|
||||
@@ -38,10 +38,10 @@ describe GitHubChangelogGenerator::Generator do
|
||||
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2))
|
||||
end
|
||||
subject do
|
||||
@generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3)))
|
||||
@generator.get_filtered_tags(tags_from_strings(%w(1 2 3)))
|
||||
end
|
||||
it { is_expected.to be_a(Array) }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1 2))) }
|
||||
end
|
||||
|
||||
context "when between_tags filled with invalid values" do
|
||||
@@ -50,133 +50,133 @@ describe GitHubChangelogGenerator::Generator do
|
||||
end
|
||||
|
||||
subject do
|
||||
@generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3)))
|
||||
@generator.get_filtered_tags(tags_from_strings(%w(1 2 3)))
|
||||
end
|
||||
it { is_expected.to be_a(Array) }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1))) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#get_filtered_tags" do
|
||||
subject do
|
||||
generator.get_filtered_tags(tags_mash_from_strings(%w(1 2 3 4 5)))
|
||||
generator.get_filtered_tags(tags_from_strings(%w(1 2 3 4 5)))
|
||||
end
|
||||
|
||||
context "with excluded and between tags" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3), exclude_tags: %w(2)) }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1 3))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1 3))) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#filter_excluded_tags" do
|
||||
subject { generator.filter_excluded_tags(tags_mash_from_strings(%w(1 2 3))) }
|
||||
subject { generator.filter_excluded_tags(tags_from_strings(%w(1 2 3))) }
|
||||
|
||||
context "with matching string" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w(3)) }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1 2))) }
|
||||
end
|
||||
|
||||
context "with non-matching string" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w(invalid tags)) }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) }
|
||||
end
|
||||
|
||||
context "with matching regex" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: /[23]/) }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1))) }
|
||||
end
|
||||
|
||||
context "with non-matching regex" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: /[abc]/) }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#filter_excluded_tags_regex" do
|
||||
subject { generator.filter_excluded_tags(tags_mash_from_strings(%w(1 2 3))) }
|
||||
subject { generator.filter_excluded_tags(tags_from_strings(%w(1 2 3))) }
|
||||
|
||||
context "with matching regex" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[23]") }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1))) }
|
||||
end
|
||||
|
||||
context "with non-matching regex" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[45]") }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#filter_since_tag" do
|
||||
context "with filled array" do
|
||||
subject { generator.filter_since_tag(tags_mash_from_strings(%w(1 2 3))) }
|
||||
subject { generator.filter_since_tag(tags_from_strings(%w(1 2 3))) }
|
||||
|
||||
context "with valid since tag" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1))) }
|
||||
end
|
||||
|
||||
context "with invalid since tag" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "Invalid tag") }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) }
|
||||
end
|
||||
end
|
||||
|
||||
context "with empty array" do
|
||||
subject { generator.filter_since_tag(tags_mash_from_strings(%w())) }
|
||||
subject { generator.filter_since_tag(tags_from_strings(%w())) }
|
||||
|
||||
context "with valid since tag" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w())) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w())) }
|
||||
end
|
||||
|
||||
context "with invalid since tag" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "Invalid tag") }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w())) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w())) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#filter_due_tag" do
|
||||
context "with filled array" do
|
||||
subject { generator.filter_due_tag(tags_mash_from_strings(%w(1 2 3))) }
|
||||
subject { generator.filter_due_tag(tags_from_strings(%w(1 2 3))) }
|
||||
|
||||
context "with valid due tag" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "2") }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(3))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(3))) }
|
||||
end
|
||||
|
||||
context "with invalid due tag" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "Invalid tag") }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) }
|
||||
end
|
||||
end
|
||||
|
||||
context "with empty array" do
|
||||
subject { generator.filter_due_tag(tags_mash_from_strings(%w())) }
|
||||
subject { generator.filter_due_tag(tags_from_strings(%w())) }
|
||||
|
||||
context "with valid due tag" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "2") }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w())) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w())) }
|
||||
end
|
||||
|
||||
context "with invalid due tag" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "Invalid tag") }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_mash_from_strings(%w())) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w())) }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -191,7 +191,7 @@ describe GitHubChangelogGenerator::Generator do
|
||||
end
|
||||
context "fetch already filled tag" do
|
||||
before { @generator.instance_variable_set :@tag_times_hash, "valid_tag" => current_time }
|
||||
subject { @generator.get_time_of_tag tag_mash_with_name("valid_tag") }
|
||||
subject { @generator.get_time_of_tag tag_with_name("valid_tag") }
|
||||
it { is_expected.to be_a_kind_of(Time) }
|
||||
it { is_expected.to eq(current_time) }
|
||||
end
|
||||
@@ -202,7 +202,7 @@ describe GitHubChangelogGenerator::Generator do
|
||||
@generator.instance_variable_set :@fetcher, mock
|
||||
end
|
||||
subject do
|
||||
of_tag = @generator.get_time_of_tag(tag_mash_with_name("valid_tag"))
|
||||
of_tag = @generator.get_time_of_tag(tag_with_name("valid_tag"))
|
||||
of_tag
|
||||
end
|
||||
it { is_expected.to be_a_kind_of(Time) }
|
||||
@@ -229,13 +229,13 @@ describe GitHubChangelogGenerator::Generator do
|
||||
@generator.sort_tags_by_date(tags)
|
||||
end
|
||||
context "sort unsorted tags" do
|
||||
let(:tags) { tags_mash_from_strings %w(valid_tag1 valid_tag2 valid_tag3) }
|
||||
let(:tags) { tags_from_strings %w(valid_tag1 valid_tag2 valid_tag3) }
|
||||
|
||||
it { is_expected.to be_a_kind_of(Array) }
|
||||
it { is_expected.to match_array(tags.reverse!) }
|
||||
end
|
||||
context "sort sorted tags" do
|
||||
let(:tags) { tags_mash_from_strings %w(valid_tag3 valid_tag2 valid_tag1) }
|
||||
let(:tags) { tags_from_strings %w(valid_tag3 valid_tag2 valid_tag1) }
|
||||
|
||||
it { is_expected.to be_a_kind_of(Array) }
|
||||
it { is_expected.to match_array(tags) }
|
||||
|
||||
@@ -4,14 +4,13 @@ INVALID_TOKEN = "0000000000000000"
|
||||
describe GitHubChangelogGenerator::OctoFetcher do
|
||||
let(:options) do
|
||||
{
|
||||
:user => "skywinder",
|
||||
:project => "changelog_test",
|
||||
user: "skywinder",
|
||||
project: "changelog_test"
|
||||
}
|
||||
end
|
||||
|
||||
let(:fetcher) { GitHubChangelogGenerator::OctoFetcher.new(options) }
|
||||
|
||||
|
||||
describe "#fetch_github_token" do
|
||||
token = GitHubChangelogGenerator::OctoFetcher::CHANGELOG_GITHUB_TOKEN
|
||||
context "when token in ENV exist" do
|
||||
@@ -27,7 +26,7 @@ describe GitHubChangelogGenerator::OctoFetcher do
|
||||
end
|
||||
|
||||
context "when token in options and ENV is nil" do
|
||||
let(:options) { { :token => VALID_TOKEN } }
|
||||
let(:options) { { token: VALID_TOKEN } }
|
||||
|
||||
before do
|
||||
stub_const("ENV", ENV.to_hash.merge(token => nil))
|
||||
@@ -38,7 +37,7 @@ describe GitHubChangelogGenerator::OctoFetcher do
|
||||
end
|
||||
|
||||
context "when token in options and ENV specified" do
|
||||
let(:options) { { :token => VALID_TOKEN } }
|
||||
let(:options) { { token: VALID_TOKEN } }
|
||||
|
||||
before do
|
||||
stub_const("ENV", ENV.to_hash.merge(token => "no_matter_what"))
|
||||
@@ -52,7 +51,7 @@ describe GitHubChangelogGenerator::OctoFetcher do
|
||||
describe "#get_all_tags" do
|
||||
context "when github_fetch_tags returns tags" do
|
||||
it "returns tags" do
|
||||
mock_tags = ['tag']
|
||||
mock_tags = ["tag"]
|
||||
allow(fetcher).to receive(:github_fetch_tags).and_return(mock_tags)
|
||||
expect(fetcher.get_all_tags).to eq(mock_tags)
|
||||
end
|
||||
@@ -65,9 +64,9 @@ describe GitHubChangelogGenerator::OctoFetcher do
|
||||
|
||||
let(:options) do
|
||||
{
|
||||
:user => "skywinder",
|
||||
:project => "changelog_test",
|
||||
:token => INVALID_TOKEN
|
||||
user: "skywinder",
|
||||
project: "changelog_test",
|
||||
token: INVALID_TOKEN
|
||||
}
|
||||
end
|
||||
|
||||
@@ -80,7 +79,42 @@ describe GitHubChangelogGenerator::OctoFetcher do
|
||||
use_vcr_cassette
|
||||
|
||||
it "should return tags" do
|
||||
expected_tags = [{"name"=>"v0.0.3", "zipball_url"=>"https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.3", "tarball_url"=>"https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.3", "commit"=>{"sha"=>"a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90", "url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90"}}, {"name"=>"v0.0.2", "zipball_url"=>"https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.2", "tarball_url"=>"https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.2", "commit"=>{"sha"=>"9b35bb13dcd15b68e7bcbf10cde5eb937a54f710", "url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/9b35bb13dcd15b68e7bcbf10cde5eb937a54f710"}}, {"name"=>"v0.0.1", "zipball_url"=>"https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.1", "tarball_url"=>"https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.1", "commit"=>{"sha"=>"4c2d6d1ed58bdb24b870dcb5d9f2ceed0283d69d", "url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/4c2d6d1ed58bdb24b870dcb5d9f2ceed0283d69d"}}, {"name"=>"0.0.4", "zipball_url"=>"https://api.github.com/repos/skywinder/changelog_test/zipball/0.0.4", "tarball_url"=>"https://api.github.com/repos/skywinder/changelog_test/tarball/0.0.4", "commit"=>{"sha"=>"ece0c3ab7142b21064b885061c55ede00ef6ce94", "url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/ece0c3ab7142b21064b885061c55ede00ef6ce94"}}]
|
||||
expected_tags = [{ "name" => "v0.0.3",
|
||||
"zipball_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.3",
|
||||
"tarball_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.3",
|
||||
"commit" =>
|
||||
{ "sha" => "a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90",
|
||||
"url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/commits/a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90" } },
|
||||
{ "name" => "v0.0.2",
|
||||
"zipball_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.2",
|
||||
"tarball_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.2",
|
||||
"commit" =>
|
||||
{ "sha" => "9b35bb13dcd15b68e7bcbf10cde5eb937a54f710",
|
||||
"url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/commits/9b35bb13dcd15b68e7bcbf10cde5eb937a54f710" } },
|
||||
{ "name" => "v0.0.1",
|
||||
"zipball_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.1",
|
||||
"tarball_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.1",
|
||||
"commit" =>
|
||||
{ "sha" => "4c2d6d1ed58bdb24b870dcb5d9f2ceed0283d69d",
|
||||
"url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/commits/4c2d6d1ed58bdb24b870dcb5d9f2ceed0283d69d" } },
|
||||
{ "name" => "0.0.4",
|
||||
"zipball_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/zipball/0.0.4",
|
||||
"tarball_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/tarball/0.0.4",
|
||||
"commit" =>
|
||||
{ "sha" => "ece0c3ab7142b21064b885061c55ede00ef6ce94",
|
||||
"url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/commits/ece0c3ab7142b21064b885061c55ede00ef6ce94" } }]
|
||||
|
||||
expect(fetcher.github_fetch_tags).to eq(expected_tags)
|
||||
end
|
||||
@@ -92,12 +126,10 @@ describe GitHubChangelogGenerator::OctoFetcher do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "#fetch_closed_issues_and_pr" do
|
||||
context "when API call is valid" do
|
||||
use_vcr_cassette
|
||||
|
||||
|
||||
it "returns issues" do
|
||||
issues, pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
expect(issues.size).to eq(7)
|
||||
@@ -105,42 +137,127 @@ describe GitHubChangelogGenerator::OctoFetcher do
|
||||
end
|
||||
|
||||
it "returns issue with proper key/values" do
|
||||
issues, pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
expected_issue = {"url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14", "repository_url"=>"https://api.github.com/repos/skywinder/changelog_test", "labels_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14/labels{/name}", "comments_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14/comments", "events_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14/events", "html_url"=>"https://github.com/skywinder/changelog_test/issues/14", "id"=>95419412, "number"=>14, "title"=>"Issue closed from commit from PR", "user"=>{"login"=>"skywinder", "id"=>3356474, "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}, "labels"=>[], "state"=>"closed", "locked"=>false, "assignee"=>nil, "milestone"=>nil, "comments"=>0, "created_at"=>"2015-07-16T12:06:08Z", "updated_at"=>"2015-07-16T12:21:42Z", "closed_at"=>"2015-07-16T12:21:42Z", "body"=>""}
|
||||
issues, _pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
expected_issue = { "url" => "https://api.github.com/repos/skywinder/changelog_test/issues/14",
|
||||
"repository_url" => "https://api.github.com/repos/skywinder/changelog_test",
|
||||
"labels_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/issues/14/labels{/name}",
|
||||
"comments_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/issues/14/comments",
|
||||
"events_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/issues/14/events",
|
||||
"html_url" => "https://github.com/skywinder/changelog_test/issues/14",
|
||||
"id" => 95_419_412,
|
||||
"number" => 14,
|
||||
"title" => "Issue closed from commit from PR",
|
||||
"user" =>
|
||||
{ "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 },
|
||||
"labels" => [],
|
||||
"state" => "closed",
|
||||
"locked" => false,
|
||||
"assignee" => nil,
|
||||
"milestone" => nil,
|
||||
"comments" => 0,
|
||||
"created_at" => "2015-07-16T12:06:08Z",
|
||||
"updated_at" => "2015-07-16T12:21:42Z",
|
||||
"closed_at" => "2015-07-16T12:21:42Z",
|
||||
"body" => "" }
|
||||
# Convert times to Time
|
||||
expected_issue.each_pair do |k,v|
|
||||
if v =~ /^2015-/
|
||||
expected_issue[k] = Time.parse(v)
|
||||
end
|
||||
expected_issue.each_pair do |k, v|
|
||||
expected_issue[k] = Time.parse(v) if v =~ /^2015-/
|
||||
end
|
||||
|
||||
expect(issues.first).to eq(expected_issue)
|
||||
end
|
||||
|
||||
it "returns pull request with proper key/values" do
|
||||
issues, pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
expected_pr = {"url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/21", "repository_url"=>"https://api.github.com/repos/skywinder/changelog_test", "labels_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/21/labels{/name}", "comments_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/21/comments", "events_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/21/events", "html_url"=>"https://github.com/skywinder/changelog_test/pull/21", "id"=>124925759, "number"=>21, "title"=>"Merged br (should appear in change log with #20)", "user"=>{"login"=>"skywinder", "id"=>3356474, "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}, "labels"=>[], "state"=>"closed", "locked"=>false, "assignee"=>nil, "milestone"=>nil, "comments"=>0, "created_at"=>"2016-01-05T09:24:08Z", "updated_at"=>"2016-01-05T09:26:53Z", "closed_at"=>"2016-01-05T09:24:27Z", "pull_request"=>{"url"=>"https://api.github.com/repos/skywinder/changelog_test/pulls/21", "html_url"=>"https://github.com/skywinder/changelog_test/pull/21", "diff_url"=>"https://github.com/skywinder/changelog_test/pull/21.diff", "patch_url"=>"https://github.com/skywinder/changelog_test/pull/21.patch"}, "body"=>"to test https://github.com/skywinder/github-changelog-generator/pull/305\r\nshould appear in change log with #20"}
|
||||
_issues, pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
expected_pr = { "url" => "https://api.github.com/repos/skywinder/changelog_test/issues/21",
|
||||
"repository_url" => "https://api.github.com/repos/skywinder/changelog_test",
|
||||
"labels_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/issues/21/labels{/name}",
|
||||
"comments_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/issues/21/comments",
|
||||
"events_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/issues/21/events",
|
||||
"html_url" => "https://github.com/skywinder/changelog_test/pull/21",
|
||||
"id" => 124_925_759,
|
||||
"number" => 21,
|
||||
"title" => "Merged br (should appear in change log with #20)",
|
||||
"user" =>
|
||||
{ "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 },
|
||||
"labels" => [],
|
||||
"state" => "closed",
|
||||
"locked" => false,
|
||||
"assignee" => nil,
|
||||
"milestone" => nil,
|
||||
"comments" => 0,
|
||||
"created_at" => "2016-01-05T09:24:08Z",
|
||||
"updated_at" => "2016-01-05T09:26:53Z",
|
||||
"closed_at" => "2016-01-05T09:24:27Z",
|
||||
"pull_request" =>
|
||||
{ "url" => "https://api.github.com/repos/skywinder/changelog_test/pulls/21",
|
||||
"html_url" => "https://github.com/skywinder/changelog_test/pull/21",
|
||||
"diff_url" => "https://github.com/skywinder/changelog_test/pull/21.diff",
|
||||
"patch_url" => "https://github.com/skywinder/changelog_test/pull/21.patch" },
|
||||
"body" =>
|
||||
"to test https://github.com/skywinder/github-changelog-generator/pull/305\r\nshould appear in change log with #20" }
|
||||
# Convert times to Time
|
||||
expected_pr.each_pair do |k,v|
|
||||
if v =~ /^2016-01/
|
||||
expected_pr[k] = Time.parse(v)
|
||||
end
|
||||
expected_pr.each_pair do |k, v|
|
||||
expected_pr[k] = Time.parse(v) if v =~ /^2016-01/
|
||||
end
|
||||
|
||||
expect(pull_requests.first).to eq(expected_pr)
|
||||
end
|
||||
|
||||
|
||||
it "returns issues with labels" do
|
||||
issues, pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
issues, _pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
expected = [[], [], ["Bug"], [], ["enhancement"], ["some label"], []]
|
||||
expect(issues.map{|i| i['labels'].map{|l| l['name']} }).to eq(expected)
|
||||
expect(issues.map { |i| i["labels"].map { |l| l["name"] } }).to eq(expected)
|
||||
end
|
||||
|
||||
it "returns pull_requests with labels" do
|
||||
issues, pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
_issues, pull_requests = fetcher.fetch_closed_issues_and_pr
|
||||
expected = [[], [], [], [], [], ["enhancement"], [], [], ["invalid"], [], [], [], [], ["invalid"]]
|
||||
expect(pull_requests.map{|i| i['labels'].map{|l| l['name']} }).to eq(expected)
|
||||
expect(pull_requests.map { |i| i["labels"].map { |l| l["name"] } }).to eq(expected)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -158,93 +275,222 @@ describe GitHubChangelogGenerator::OctoFetcher do
|
||||
pull_requests = fetcher.fetch_closed_pull_requests
|
||||
|
||||
pr = pull_requests.first
|
||||
expect(pr.keys).to eq(["url", "id", "html_url", "diff_url", "patch_url", "issue_url", "number", "state", "locked", "title", "user", "body", "created_at", "updated_at", "closed_at", "merged_at", "merge_commit_sha", "assignee", "milestone", "commits_url", "review_comments_url", "review_comment_url", "comments_url", "statuses_url", "head", "base", "_links"])
|
||||
expect(pr.keys).to eq(%w(url id html_url diff_url patch_url issue_url number state locked title user body created_at updated_at closed_at merged_at merge_commit_sha assignee milestone commits_url review_comments_url review_comment_url comments_url statuses_url head base _links))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "#fetch_events_async" do
|
||||
context "when API call is valid" do
|
||||
use_vcr_cassette
|
||||
|
||||
it "populates issues" do
|
||||
issues = [{"url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14", "repository_url"=>"https://api.github.com/repos/skywinder/changelog_test", "labels_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14/labels{/name}", "comments_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14/comments", "events_url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/14/events", "html_url"=>"https://github.com/skywinder/changelog_test/issues/14", "id"=>95419412, "number"=>14, "title"=>"Issue closed from commit from PR", "user"=>{"login"=>"skywinder", "id"=>3356474, "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}, "labels"=>[], "state"=>"closed", "locked"=>false, "assignee"=>nil, "milestone"=>nil, "comments"=>0, "created_at"=>"2015-07-16T12:06:08Z", "updated_at"=>"2015-07-16T12:21:42Z", "closed_at"=>"2015-07-16T12:21:42Z", "body"=>""}]
|
||||
issues = [{ "url" => "https://api.github.com/repos/skywinder/changelog_test/issues/14",
|
||||
"repository_url" => "https://api.github.com/repos/skywinder/changelog_test",
|
||||
"labels_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/issues/14/labels{/name}",
|
||||
"comments_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/issues/14/comments",
|
||||
"events_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/issues/14/events",
|
||||
"html_url" => "https://github.com/skywinder/changelog_test/issues/14",
|
||||
"id" => 95_419_412,
|
||||
"number" => 14,
|
||||
"title" => "Issue closed from commit from PR",
|
||||
"user" =>
|
||||
{ "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 },
|
||||
"labels" => [],
|
||||
"state" => "closed",
|
||||
"locked" => false,
|
||||
"assignee" => nil,
|
||||
"milestone" => nil,
|
||||
"comments" => 0,
|
||||
"created_at" => "2015-07-16T12:06:08Z",
|
||||
"updated_at" => "2015-07-16T12:21:42Z",
|
||||
"closed_at" => "2015-07-16T12:21:42Z",
|
||||
"body" => "" }]
|
||||
|
||||
# Check that they are blank to begin with
|
||||
expect(issues.first['events']).to be_nil
|
||||
expect(issues.first["events"]).to be_nil
|
||||
|
||||
fetcher.fetch_events_async(issues)
|
||||
issue_events = issues.first['events']
|
||||
issue_events = issues.first["events"]
|
||||
|
||||
expected_events = [{"id"=>357462189, "url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/events/357462189", "actor"=>{"login"=>"skywinder", "id"=>3356474, "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}, "event"=>"referenced", "commit_id"=>"decfe840d1a1b86e0c28700de5362d3365a29555", "commit_url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555", "created_at"=>"2015-07-16T12:21:16Z"}, {"id"=>357462542, "url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/events/357462542", "actor"=>{"login"=>"skywinder", "id"=>3356474, "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}, "event"=>"closed", "commit_id"=>"decfe840d1a1b86e0c28700de5362d3365a29555", "commit_url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555", "created_at"=>"2015-07-16T12:21:42Z"}]
|
||||
expected_events = [{ "id" => 357_462_189,
|
||||
"url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/issues/events/357462189",
|
||||
"actor" =>
|
||||
{ "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 },
|
||||
"event" => "referenced",
|
||||
"commit_id" => "decfe840d1a1b86e0c28700de5362d3365a29555",
|
||||
"commit_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555",
|
||||
"created_at" => "2015-07-16T12:21:16Z" },
|
||||
{ "id" => 357_462_542,
|
||||
"url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/issues/events/357462542",
|
||||
"actor" =>
|
||||
{ "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 },
|
||||
"event" => "closed",
|
||||
"commit_id" => "decfe840d1a1b86e0c28700de5362d3365a29555",
|
||||
"commit_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555",
|
||||
"created_at" => "2015-07-16T12:21:42Z" }]
|
||||
|
||||
# Convert times to Time
|
||||
expected_events.map! do |event|
|
||||
event.each_pair do |k, v|
|
||||
if v =~ /^201[56]-/
|
||||
event[k] = Time.parse(v)
|
||||
end
|
||||
event[k] = Time.parse(v) if v =~ /^201[56]-/
|
||||
end
|
||||
end
|
||||
|
||||
expect(issue_events).to eq(expected_events)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "#fetch_date_of_tag" do
|
||||
context "when API call is valid" do
|
||||
use_vcr_cassette
|
||||
|
||||
it "returns date" do
|
||||
tag = {"name"=>"v0.0.3", "zipball_url"=>"https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.3", "tarball_url"=>"https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.3", "commit"=>{"sha"=>"a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90", "url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90"}}
|
||||
tag = { "name" => "v0.0.3",
|
||||
"zipball_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/zipball/v0.0.3",
|
||||
"tarball_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/tarball/v0.0.3",
|
||||
"commit" =>
|
||||
{ "sha" => "a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90",
|
||||
"url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/commits/a0cba2b1a1ea9011ab07ee1ac140ba5a5eb8bd90" } }
|
||||
|
||||
dt = fetcher.fetch_date_of_tag(tag)
|
||||
expect(dt).to eq(Time.parse("2015-03-04 19:01:48 UTC"))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "#fetch_commit" do
|
||||
context "when API call is valid" do
|
||||
use_vcr_cassette
|
||||
|
||||
it "returns commit" do
|
||||
event = {"id"=>357462189, "url"=>"https://api.github.com/repos/skywinder/changelog_test/issues/events/357462189", "actor"=>{"login"=>"skywinder", "id"=>3356474, "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}, "event"=>"referenced", "commit_id"=>"decfe840d1a1b86e0c28700de5362d3365a29555", "commit_url"=>"https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555", "created_at"=>"2015-07-16T12:21:16Z"}
|
||||
event = { "id" => 357_462_189,
|
||||
"url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/issues/events/357462189",
|
||||
"actor" =>
|
||||
{ "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 },
|
||||
"event" => "referenced",
|
||||
"commit_id" => "decfe840d1a1b86e0c28700de5362d3365a29555",
|
||||
"commit_url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555",
|
||||
"created_at" => "2015-07-16T12:21:16Z" }
|
||||
commit = fetcher.fetch_commit(event)
|
||||
|
||||
expectations = [
|
||||
["sha", "decfe840d1a1b86e0c28700de5362d3365a29555"],
|
||||
%w(sha decfe840d1a1b86e0c28700de5362d3365a29555),
|
||||
["url",
|
||||
"https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555"],
|
||||
# OLD API: "https://api.github.com/repos/skywinder/changelog_test/git/commits/decfe840d1a1b86e0c28700de5362d3365a29555"],
|
||||
["html_url",
|
||||
"https://github.com/skywinder/changelog_test/commit/decfe840d1a1b86e0c28700de5362d3365a29555"],
|
||||
["author",
|
||||
{"login"=>"skywinder", "id"=>3356474, "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}],
|
||||
{ "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 }],
|
||||
["committer",
|
||||
{"login"=>"skywinder", "id"=>3356474, "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}],
|
||||
{ "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 }],
|
||||
["parents",
|
||||
[{"sha"=>"7ec095e5e3caceacedabf44d0b9b10da17c92e51",
|
||||
"url"=>
|
||||
[{ "sha" => "7ec095e5e3caceacedabf44d0b9b10da17c92e51",
|
||||
"url" =>
|
||||
"https://api.github.com/repos/skywinder/changelog_test/commits/7ec095e5e3caceacedabf44d0b9b10da17c92e51",
|
||||
# OLD API: "https://api.github.com/repos/skywinder/changelog_test/git/commits/7ec095e5e3caceacedabf44d0b9b10da17c92e51",
|
||||
"html_url"=>
|
||||
"https://github.com/skywinder/changelog_test/commit/7ec095e5e3caceacedabf44d0b9b10da17c92e51"}]
|
||||
# OLD API: "https://api.github.com/repos/skywinder/changelog_test/git/commits/7ec095e5e3caceacedabf44d0b9b10da17c92e51",
|
||||
"html_url" =>
|
||||
"https://github.com/skywinder/changelog_test/commit/7ec095e5e3caceacedabf44d0b9b10da17c92e51" }]
|
||||
]
|
||||
]
|
||||
|
||||
expectations.each do |property, val|
|
||||
expect(commit[property]).to eq(val)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user