Welcome to mirror list, hosted at ThFree Co, Russian Federation.

renderer_spec.rb « docs « usage « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0677aa2d9d735421f53b4e9138db415484f7b47a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Usage::Docs::Renderer do
  describe 'contents' do
    let(:dictionary_path) { Gitlab::Usage::Docs::Renderer::DICTIONARY_PATH }
    let(:items) { Gitlab::Usage::MetricDefinition.definitions }

    it 'generates dictionary for given items' do
      generated_dictionary = described_class.new(items).contents
      generated_dictionary_keys = RDoc::Markdown
        .parse(generated_dictionary)
        .table_of_contents
        .select { |metric_doc| metric_doc.level == 2 && !metric_doc.text.start_with?('info:') }
        .map(&:text)
        .map { |text| text.sub('<code>', '').sub('</code>', '') }

      expect(generated_dictionary_keys).to match_array(items.keys)
    end
  end
end