@@ -1,4 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module GitHubChangelogGenerator
|
||||
describe Generator do
|
||||
context "#exclude_issues_by_labels" do
|
||||
@@ -7,7 +8,7 @@ module GitHubChangelogGenerator
|
||||
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)) }
|
||||
subject(:generator) { described_class.new(exclude_labels: %w[BAD BOO]) }
|
||||
|
||||
it "removes issues with labels in the exclude_label list" do
|
||||
result = generator.exclude_issues_by_labels(issues)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe GitHubChangelogGenerator::Generator do
|
||||
def tag_with_name(tag)
|
||||
{
|
||||
@@ -19,167 +20,167 @@ describe GitHubChangelogGenerator::Generator do
|
||||
end
|
||||
|
||||
subject do
|
||||
@generator.get_filtered_tags(tags_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_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))
|
||||
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w[1 2 3])
|
||||
end
|
||||
subject do
|
||||
@generator.get_filtered_tags(tags_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_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
|
||||
before do
|
||||
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2))
|
||||
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w[1 2])
|
||||
end
|
||||
subject do
|
||||
@generator.get_filtered_tags(tags_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_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
|
||||
before do
|
||||
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 q w))
|
||||
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w[1 q w])
|
||||
end
|
||||
|
||||
subject do
|
||||
@generator.get_filtered_tags(tags_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_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_from_strings(%w(1 2 3 4 5)))
|
||||
generator.get_filtered_tags(tags_from_strings(%w[1 2 3 4 5]))
|
||||
end
|
||||
|
||||
context "respects between tags" do
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3)) }
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(between_tags: %w[1 2 3]) }
|
||||
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_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" do
|
||||
subject { generator.filter_excluded_tags(tags_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)) }
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w[3]) }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_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)) }
|
||||
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w[invalid tags]) }
|
||||
it { is_expected.to be_a Array }
|
||||
it { is_expected.to match_array(tags_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_from_strings(%w())) }
|
||||
it { is_expected.to match_array(tags_from_strings(%w[])) }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -232,13 +233,13 @@ describe GitHubChangelogGenerator::Generator do
|
||||
@generator.sort_tags_by_date(tags)
|
||||
end
|
||||
context "sort unsorted tags" do
|
||||
let(:tags) { tags_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_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) }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
VALID_TOKEN = "0123456789abcdef"
|
||||
INVALID_TOKEN = "0000000000000000"
|
||||
|
||||
@@ -299,7 +300,7 @@ describe GitHubChangelogGenerator::OctoFetcher do
|
||||
pull_requests = fetcher.fetch_closed_pull_requests
|
||||
|
||||
pr = pull_requests.first
|
||||
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 assignees 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 assignees milestone commits_url review_comments_url review_comment_url comments_url statuses_url head base _links])
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -500,7 +501,7 @@ describe GitHubChangelogGenerator::OctoFetcher do
|
||||
commit = fetcher.fetch_commit(event)
|
||||
|
||||
expectations = [
|
||||
%w(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"],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe GitHubChangelogGenerator::Options do
|
||||
describe "#initialize" do
|
||||
context "with known options" do
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe GitHubChangelogGenerator::ParserFile do
|
||||
describe ".github_changelog_generator" do
|
||||
let(:options) { {} }
|
||||
@@ -13,7 +14,7 @@ describe GitHubChangelogGenerator::ParserFile do
|
||||
let(:parser) { GitHubChangelogGenerator::ParserFile.new(options, StringIO.new("")) }
|
||||
|
||||
it "does not change the options" do
|
||||
expect { parser.parse! }.to_not change { options }
|
||||
expect { parser.parse! }.to_not(change { options })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,12 +52,11 @@ describe GitHubChangelogGenerator::ParserFile do
|
||||
|
||||
context "turns exclude-labels into an Array", bug: "#327" do
|
||||
let(:file) do
|
||||
StringIO.new(<<EOF
|
||||
exclude-labels=73a91042-da6f-11e5-9335-1040f38d7f90,7adf83b4-da6f-11e5-ae18-1040f38d7f90
|
||||
header_label=# My changelog
|
||||
EOF
|
||||
)
|
||||
line1 = "exclude-labels=73a91042-da6f-11e5-9335-1040f38d7f90,7adf83b4-da6f-11e5-ae18-1040f38d7f90\n"
|
||||
line2 = "header_label=# My changelog\n"
|
||||
StringIO.new(line1 + line2)
|
||||
end
|
||||
|
||||
it "reads exclude_labels into an Array" do
|
||||
expect { parser.parse! }.to change { options[:exclude_labels] }
|
||||
.from(default_options[:exclude_labels])
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe GitHubChangelogGenerator::Parser do
|
||||
describe ".user_project_from_remote" do
|
||||
context "when remote is type 1" do
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Author:: Enrico Stahn <mail@enricostahn.com>
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user