Chore: Rubocop 0.49.0 (#516)

* Rubocoping
This commit is contained in:
Olle Jonsson 2017-05-25 00:11:02 +02:00 committed by GitHub
parent 26b124a67c
commit 874c23c64f
22 changed files with 132 additions and 116 deletions

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
source "https://rubygems.org" source "https://rubygems.org"
ruby RUBY_VERSION ruby RUBY_VERSION

View File

@ -1,5 +1,6 @@
# coding: utf-8 # coding: utf-8
# frozen_string_literal: true # frozen_string_literal: true
lib = File.expand_path("../lib", __FILE__) lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "github_changelog_generator/version" require "github_changelog_generator/version"
@ -18,7 +19,7 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/skywinder/Github-Changelog-Generator" spec.homepage = "https://github.com/skywinder/Github-Changelog-Generator"
spec.license = "MIT" spec.license = "MIT"
spec.files = Dir["{bin,lib,man,spec}/**/*"] + %w(LICENSE Rakefile README.md) spec.files = Dir["{bin,lib,man,spec}/**/*"] + %w[LICENSE Rakefile README.md]
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.test_files = spec.files.grep(%r{^(test|spec|features)/})

View File

@ -9,13 +9,13 @@ require "json"
require "multi_json" require "multi_json"
require "benchmark" require "benchmark"
require_relative "github_changelog_generator/helper" require "github_changelog_generator/helper"
require_relative "github_changelog_generator/options" require "github_changelog_generator/options"
require_relative "github_changelog_generator/parser" require "github_changelog_generator/parser"
require_relative "github_changelog_generator/parser_file" require "github_changelog_generator/parser_file"
require_relative "github_changelog_generator/generator/generator" require "github_changelog_generator/generator/generator"
require_relative "github_changelog_generator/version" require "github_changelog_generator/version"
require_relative "github_changelog_generator/reader" require "github_changelog_generator/reader"
# The main module, where placed all classes (now, at least) # The main module, where placed all classes (now, at least)
module GitHubChangelogGenerator module GitHubChangelogGenerator
@ -33,14 +33,10 @@ module GitHubChangelogGenerator
def run def run
log = @generator.compound_changelog log = @generator.compound_changelog
output_filename = (@options[:output]).to_s output_filename = @options[:output].to_s
File.open(output_filename, "w") { |file| file.write(log) } File.open(output_filename, "wb") { |file| file.write(log) }
puts "Done!" puts "Done!"
puts "Generated log placed in #{Dir.pwd}/#{output_filename}" puts "Generated log placed in #{Dir.pwd}/#{output_filename}"
end end
end end
if __FILE__ == $PROGRAM_NAME
GitHubChangelogGenerator::ChangelogGenerator.new.run
end
end end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require_relative "../octo_fetcher" require_relative "../octo_fetcher"
require_relative "generator_generation" require_relative "generator_generation"
require_relative "generator_fetcher" require_relative "generator_fetcher"

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module GitHubChangelogGenerator module GitHubChangelogGenerator
class Generator class Generator
MAX_THREAD_NUMBER = 25 MAX_THREAD_NUMBER = 25

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module GitHubChangelogGenerator module GitHubChangelogGenerator
class Generator class Generator
# Main function to start change log generation # Main function to start change log generation

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module GitHubChangelogGenerator module GitHubChangelogGenerator
class Generator class Generator
# delete all labels with labels from options[:exclude_labels] array # delete all labels with labels from options[:exclude_labels] array
@ -132,8 +133,8 @@ module GitHubChangelogGenerator
# @return [Array] issues without labels or empty array if add_issues_wo_labels is false # @return [Array] issues without labels or empty array if add_issues_wo_labels is false
def filter_wo_labels(issues) def filter_wo_labels(issues)
if options[:add_issues_wo_labels] if options[:add_issues_wo_labels]
issues_wo_labels = issues.select do |issue| issues_wo_labels = issues.reject do |issue|
!issue["labels"].map { |l| l["name"] }.any? issue["labels"].map { |l| l["name"] }.none?
end end
return issues_wo_labels return issues_wo_labels
end end
@ -197,8 +198,8 @@ module GitHubChangelogGenerator
end end
end end
pull_requests.select! do |pr| pull_requests.reject! do |pr|
!pr["merged_at"].nil? pr["merged_at"].nil?
end end
pull_requests pull_requests

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module GitHubChangelogGenerator module GitHubChangelogGenerator
class Generator class Generator
# fetch, filter tags, fetch dates and sort them in time order # fetch, filter tags, fetch dates and sort them in time order

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require "logger" require "logger"
require "rainbow" require "rainbow"

View File

@ -1,56 +1,57 @@
# frozen_string_literal: true # frozen_string_literal: true
require "delegate" require "delegate"
module GitHubChangelogGenerator module GitHubChangelogGenerator
class Options < SimpleDelegator class Options < SimpleDelegator
UnsupportedOptionError = Class.new(ArgumentError) UnsupportedOptionError = Class.new(ArgumentError)
KNOWN_OPTIONS = [ KNOWN_OPTIONS = %i[
:add_issues_wo_labels, add_issues_wo_labels
:add_pr_wo_labels, add_pr_wo_labels
:author, author
:base, base
:between_tags, between_tags
:bug_labels, bug_labels
:bug_prefix, bug_prefix
:cache_file, cache_file
:cache_log, cache_log
:compare_link, compare_link
:date_format, date_format
:due_tag, due_tag
:enhancement_labels, enhancement_labels
:enhancement_prefix, enhancement_prefix
:exclude_labels, exclude_labels
:exclude_tags, exclude_tags
:exclude_tags_regex, exclude_tags_regex
:filter_issues_by_milestone, filter_issues_by_milestone
:frontmatter, frontmatter
:future_release, future_release
:git_remote, git_remote
:github_endpoint, github_endpoint
:github_site, github_site
:header, header
:http_cache, http_cache
:include_labels, include_labels
:issue_prefix, issue_prefix
:issue_line_labels, issue_line_labels
:issues, issues
:max_issues, max_issues
:merge_prefix, merge_prefix
:output, output
:project, project
:pulls, pulls
:release_branch, release_branch
:release_url, release_url
:simple_list, simple_list
:since_tag, since_tag
:ssl_ca_file, ssl_ca_file
:token, token
:unreleased, unreleased
:unreleased_label, unreleased_label
:unreleased_only, unreleased_only
:user, user
:usernames_as_github_logins, usernames_as_github_logins
:verbose verbose
] ]
def initialize(values) def initialize(values)

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require "pathname" require "pathname"
module GitHubChangelogGenerator module GitHubChangelogGenerator
@ -65,8 +66,8 @@ module GitHubChangelogGenerator
[key.tr("-", "_").to_sym, value.gsub(/[\n\r]+/, "")] [key.tr("-", "_").to_sym, value.gsub(/[\n\r]+/, "")]
end end
KNOWN_ARRAY_KEYS = [:exclude_labels, :include_labels, :bug_labels, KNOWN_ARRAY_KEYS = %i[exclude_labels include_labels bug_labels
:enhancement_labels, :issue_line_labels, :between_tags, :exclude_tags] enhancement_labels issue_line_labels between_tags exclude_tags]
KNOWN_INTEGER_KEYS = [:max_issues] KNOWN_INTEGER_KEYS = [:max_issues]
def convert_value(value, option_name) def convert_value(value, option_name)

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# #
# Author:: Enrico Stahn <mail@enricostahn.com> # Author:: Enrico Stahn <mail@enricostahn.com>
# #

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require "rake" require "rake"
require "rake/tasklib" require "rake/tasklib"
require "github_changelog_generator" require "github_changelog_generator"
@ -7,7 +8,7 @@ module GitHubChangelogGenerator
class RakeTask < ::Rake::TaskLib class RakeTask < ::Rake::TaskLib
include ::Rake::DSL if defined?(::Rake::DSL) include ::Rake::DSL if defined?(::Rake::DSL)
OPTIONS = %w( user project token date_format output OPTIONS = %w[ user project token date_format output
bug_prefix enhancement_prefix issue_prefix bug_prefix enhancement_prefix issue_prefix
header merge_prefix issues header merge_prefix issues
add_issues_wo_labels add_pr_wo_labels add_issues_wo_labels add_pr_wo_labels
@ -18,7 +19,7 @@ module GitHubChangelogGenerator
between_tags exclude_tags exclude_tags_regex since_tag max_issues between_tags exclude_tags exclude_tags_regex since_tag max_issues
github_site github_endpoint simple_list github_site github_endpoint simple_list
future_release release_branch verbose release_url future_release release_branch verbose release_url
base ) base ]
OPTIONS.each do |o| OPTIONS.each do |o|
attr_accessor o.to_sym attr_accessor o.to_sym

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module GitHubChangelogGenerator module GitHubChangelogGenerator
VERSION = "1.14.3" VERSION = "1.14.3"
end end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# #
# Author:: Enrico Stahn <mail@enricostahn.com> # Author:: Enrico Stahn <mail@enricostahn.com>
# #

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module GitHubChangelogGenerator module GitHubChangelogGenerator
describe Generator do describe Generator do
context "#exclude_issues_by_labels" do context "#exclude_issues_by_labels" do
@ -7,7 +8,7 @@ module GitHubChangelogGenerator
let(:good_label) { { "name" => "GOOD" } } let(:good_label) { { "name" => "GOOD" } }
let(:good_issue) { { "labels" => [good_label] } } let(:good_issue) { { "labels" => [good_label] } }
let(:issues) { [issue, good_issue] } 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 it "removes issues with labels in the exclude_label list" do
result = generator.exclude_issues_by_labels(issues) result = generator.exclude_issues_by_labels(issues)

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
describe GitHubChangelogGenerator::Generator do describe GitHubChangelogGenerator::Generator do
def tag_with_name(tag) def tag_with_name(tag)
{ {
@ -19,167 +20,167 @@ describe GitHubChangelogGenerator::Generator do
end end
subject do 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 end
it { is_expected.to be_a(Array) } 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 "when between_tags same as input array" do context "when between_tags same as input array" do
before do before do
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3)) @generator = GitHubChangelogGenerator::Generator.new(between_tags: %w[1 2 3])
end end
subject do 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 end
it { is_expected.to be_a(Array) } 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 "when between_tags filled with correct values" do context "when between_tags filled with correct values" do
before do before do
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2)) @generator = GitHubChangelogGenerator::Generator.new(between_tags: %w[1 2])
end end
subject do 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 end
it { is_expected.to be_a(Array) } 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 end
context "when between_tags filled with invalid values" do context "when between_tags filled with invalid values" do
before do before do
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 q w)) @generator = GitHubChangelogGenerator::Generator.new(between_tags: %w[1 q w])
end end
subject do 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 end
it { is_expected.to be_a(Array) } 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
end end
describe "#get_filtered_tags" do describe "#get_filtered_tags" do
subject 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 end
context "respects between tags" do 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 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
end end
describe "#filter_excluded_tags" do 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 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 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 end
context "with non-matching string" do 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 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 matching regex" do context "with matching regex" do
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: /[23]/) } let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: /[23]/) }
it { is_expected.to be_a Array } 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
context "with non-matching regex" do context "with non-matching regex" do
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: /[abc]/) } let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: /[abc]/) }
it { is_expected.to be_a Array } 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
end end
describe "#filter_excluded_tags_regex" do 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 context "with matching regex" do
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[23]") } let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[23]") }
it { is_expected.to be_a Array } 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
context "with non-matching regex" do context "with non-matching regex" do
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[45]") } let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[45]") }
it { is_expected.to be_a Array } 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
end end
describe "#filter_since_tag" do describe "#filter_since_tag" do
context "with filled array" 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 context "with valid since tag" do
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") } let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") }
it { is_expected.to be_a Array } 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
context "with invalid since tag" do context "with invalid since tag" do
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "Invalid tag") } let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "Invalid tag") }
it { is_expected.to be_a Array } 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
end end
context "with empty array" do 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 context "with valid since tag" do
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") } let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "2") }
it { is_expected.to be_a Array } 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
context "with invalid since tag" do context "with invalid since tag" do
let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "Invalid tag") } let(:generator) { GitHubChangelogGenerator::Generator.new(since_tag: "Invalid tag") }
it { is_expected.to be_a Array } 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 end
end end
describe "#filter_due_tag" do describe "#filter_due_tag" do
context "with filled array" 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 context "with valid due tag" do
let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "2") } let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "2") }
it { is_expected.to be_a Array } 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 end
context "with invalid due tag" do context "with invalid due tag" do
let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "Invalid tag") } let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "Invalid tag") }
it { is_expected.to be_a Array } 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
end end
context "with empty array" do 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 context "with valid due tag" do
let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "2") } let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "2") }
it { is_expected.to be_a Array } 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
context "with invalid due tag" do context "with invalid due tag" do
let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "Invalid tag") } let(:generator) { GitHubChangelogGenerator::Generator.new(due_tag: "Invalid tag") }
it { is_expected.to be_a Array } 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 end
end end
@ -232,13 +233,13 @@ describe GitHubChangelogGenerator::Generator do
@generator.sort_tags_by_date(tags) @generator.sort_tags_by_date(tags)
end end
context "sort unsorted tags" do 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 be_a_kind_of(Array) }
it { is_expected.to match_array(tags.reverse!) } it { is_expected.to match_array(tags.reverse!) }
end end
context "sort sorted tags" do 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 be_a_kind_of(Array) }
it { is_expected.to match_array(tags) } it { is_expected.to match_array(tags) }

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
VALID_TOKEN = "0123456789abcdef" VALID_TOKEN = "0123456789abcdef"
INVALID_TOKEN = "0000000000000000" INVALID_TOKEN = "0000000000000000"
@ -299,7 +300,7 @@ describe GitHubChangelogGenerator::OctoFetcher do
pull_requests = fetcher.fetch_closed_pull_requests pull_requests = fetcher.fetch_closed_pull_requests
pr = pull_requests.first 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 end
end end
@ -500,7 +501,7 @@ describe GitHubChangelogGenerator::OctoFetcher do
commit = fetcher.fetch_commit(event) commit = fetcher.fetch_commit(event)
expectations = [ expectations = [
%w(sha decfe840d1a1b86e0c28700de5362d3365a29555), %w[sha decfe840d1a1b86e0c28700de5362d3365a29555],
["url", ["url",
"https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555"], "https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555"],
# OLD API: "https://api.github.com/repos/skywinder/changelog_test/git/commits/decfe840d1a1b86e0c28700de5362d3365a29555"], # OLD API: "https://api.github.com/repos/skywinder/changelog_test/git/commits/decfe840d1a1b86e0c28700de5362d3365a29555"],

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
RSpec.describe GitHubChangelogGenerator::Options do RSpec.describe GitHubChangelogGenerator::Options do
describe "#initialize" do describe "#initialize" do
context "with known options" do context "with known options" do

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
describe GitHubChangelogGenerator::ParserFile do describe GitHubChangelogGenerator::ParserFile do
describe ".github_changelog_generator" do describe ".github_changelog_generator" do
let(:options) { {} } let(:options) { {} }
@ -13,7 +14,7 @@ describe GitHubChangelogGenerator::ParserFile do
let(:parser) { GitHubChangelogGenerator::ParserFile.new(options, StringIO.new("")) } let(:parser) { GitHubChangelogGenerator::ParserFile.new(options, StringIO.new("")) }
it "does not change the options" do it "does not change the options" do
expect { parser.parse! }.to_not change { options } expect { parser.parse! }.to_not(change { options })
end end
end end
@ -51,12 +52,11 @@ describe GitHubChangelogGenerator::ParserFile do
context "turns exclude-labels into an Array", bug: "#327" do context "turns exclude-labels into an Array", bug: "#327" do
let(:file) do let(:file) do
StringIO.new(<<EOF line1 = "exclude-labels=73a91042-da6f-11e5-9335-1040f38d7f90,7adf83b4-da6f-11e5-ae18-1040f38d7f90\n"
exclude-labels=73a91042-da6f-11e5-9335-1040f38d7f90,7adf83b4-da6f-11e5-ae18-1040f38d7f90 line2 = "header_label=# My changelog\n"
header_label=# My changelog StringIO.new(line1 + line2)
EOF
)
end end
it "reads exclude_labels into an Array" do it "reads exclude_labels into an Array" do
expect { parser.parse! }.to change { options[:exclude_labels] } expect { parser.parse! }.to change { options[:exclude_labels] }
.from(default_options[:exclude_labels]) .from(default_options[:exclude_labels])

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
describe GitHubChangelogGenerator::Parser do describe GitHubChangelogGenerator::Parser do
describe ".user_project_from_remote" do describe ".user_project_from_remote" do
context "when remote is type 1" do context "when remote is type 1" do

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# #
# Author:: Enrico Stahn <mail@enricostahn.com> # Author:: Enrico Stahn <mail@enricostahn.com>
# #