Sha256: 836e2dc51630e8267467ac2440ecfcff02eba9b8f8258dfda2d0a99623921e99

Contents?: true

Size: 1.04 KB

Versions: 27

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require "test_helper"

class ChangelogTest < Minitest::Test
  def test_has_heading_for_current_version
    assert_includes(changelog_headings, current_version_heading)
  end

  def test_headings_are_consistent
    invalid_headings = changelog_headings.reject do |heading|
      next true if heading == "# Changelog"
      next true if heading == "## Unreleased changes"

      # Remaining headings are <h2> if and only if they are version headings, and must be formatted correctly.
      if heading.start_with?("## ") || heading.include?("Version")
        next heading.match?(/^## Version \d+\.\d+\.\d+/)
      end

      next true if heading.start_with?("###") # <h3> and lower are permitted

      false # All other headings are forbidden
    end

    assert_empty(invalid_headings, "Headings must follow formatting conventions")
  end

  private

  def current_version_heading
    "## Version #{StatsD::Instrument::VERSION}"
  end

  def changelog_headings
    File.read("CHANGELOG.md").each_line.grep(/^#/).map(&:strip)
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
statsd-instrument-3.9.9 test/changelog_test.rb
statsd-instrument-3.9.8 test/changelog_test.rb
statsd-instrument-3.9.7 test/changelog_test.rb
statsd-instrument-3.9.6 test/changelog_test.rb
statsd-instrument-3.9.5 test/changelog_test.rb
statsd-instrument-3.9.4 test/changelog_test.rb
statsd-instrument-3.9.3 test/changelog_test.rb
statsd-instrument-3.9.2 test/changelog_test.rb
statsd-instrument-3.9.1 test/changelog_test.rb
statsd-instrument-3.9.0 test/changelog_test.rb
statsd-instrument-3.8.0 test/changelog_test.rb
statsd-instrument-3.7.0 test/changelog_test.rb
statsd-instrument-3.6.1 test/changelog_test.rb
statsd-instrument-3.6.0 test/changelog_test.rb
statsd-instrument-3.5.12 test/changelog_test.rb
statsd-instrument-3.5.11 test/changelog_test.rb
statsd-instrument-3.5.10 test/changelog_test.rb
statsd-instrument-3.5.9 test/changelog_test.rb
statsd-instrument-3.5.8 test/changelog_test.rb
statsd-instrument-3.5.7 test/changelog_test.rb