debian-mirror-gitlab/spec/lib/gitlab/usage/docs/renderer_spec.rb

25 lines
765 B
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
require 'spec_helper'
2021-04-17 20:07:23 +05:30
CODE_REGEX = %r{<code>(.*)</code>}.freeze
2021-03-11 19:13:27 +05:30
RSpec.describe Gitlab::Usage::Docs::Renderer do
describe 'contents' do
let(:dictionary_path) { Gitlab::Usage::Docs::Renderer::DICTIONARY_PATH }
2021-04-17 20:07:23 +05:30
let(:items) { Gitlab::Usage::MetricDefinition.definitions.first(10).to_h }
2021-03-11 19:13:27 +05:30
it 'generates dictionary for given items' do
generated_dictionary = described_class.new(items).contents
2021-04-17 20:07:23 +05:30
2021-03-11 19:13:27 +05:30
generated_dictionary_keys = RDoc::Markdown
.parse(generated_dictionary)
.table_of_contents
2021-04-17 20:07:23 +05:30
.select { |metric_doc| metric_doc.level == 3 }
.map { |item| item.text.match(CODE_REGEX)&.captures&.first }
2021-03-11 19:13:27 +05:30
expect(generated_dictionary_keys).to match_array(items.keys)
end
end
end