From 6ad5aa106df2a9cd3db3ec5a2f628061f99cbe18 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Thu, 25 May 2017 14:07:34 +0200 Subject: [PATCH] Bug: require ActiveSupport core_ext blank (#520) --- lib/github_changelog_generator.rb | 1 + .../generator/generator.rb | 11 ++++++----- .../unit/generator/generator_generation_spec.rb | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 spec/unit/generator/generator_generation_spec.rb diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 191d330..d2af44e 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -5,6 +5,7 @@ require "octokit" require "faraday-http-cache" require "logger" require "active_support" +require "active_support/core_ext/object/blank" require "json" require "multi_json" require "benchmark" diff --git a/lib/github_changelog_generator/generator/generator.rb b/lib/github_changelog_generator/generator/generator.rb index 833e969..5e34a2b 100644 --- a/lib/github_changelog_generator/generator/generator.rb +++ b/lib/github_changelog_generator/generator/generator.rb @@ -36,16 +36,17 @@ module GitHubChangelogGenerator detect_actual_closed_dates(@issues + @pull_requests) end - # Encapsulate characters to make markdown look as expected. + ENCAPSULATED_CHARACTERS = %w(< > * _ \( \) [ ] #) + + # Encapsulate characters to make Markdown look as expected. # # @param [String] string # @return [String] encapsulated input string def encapsulate_string(string) - string.gsub! '\\', '\\\\' + string = string.gsub('\\', '\\\\') - encpas_chars = %w(< > * _ \( \) [ ] #) - encpas_chars.each do |char| - string.gsub! char, "\\#{char}" + ENCAPSULATED_CHARACTERS.each do |char| + string = string.gsub(char, "\\#{char}") end string diff --git a/spec/unit/generator/generator_generation_spec.rb b/spec/unit/generator/generator_generation_spec.rb new file mode 100644 index 0000000..c849eda --- /dev/null +++ b/spec/unit/generator/generator_generation_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module GitHubChangelogGenerator + describe Generator do + describe "#get_string_for_issue" do + let(:issue) do + { "title" => "Bug in code" } + end + + it "formats an issue according to options" do + expect do + described_class.new.get_string_for_issue(issue) + end.not_to raise_error + end + end + end +end