Skip to content

Commit bfc974d

Browse files
Earlopainbbatsov
authored andcommitted
Add a basic test for the docs generator
Nothing much, just checking that it runs without errors on all ruby versions tested in CI Followup to #13332
1 parent 76383e7 commit bfc974d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/rubocop/cops_documentation_generator.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require 'fileutils'
4+
require 'yard'
45

56
# Class for generating documentation of all cops departments
67
# @api private
@@ -295,7 +296,7 @@ def print_cops_of_department(department)
295296
HEADER
296297
selected_cops.each { |cop| content << print_cop_with_doc(cop) }
297298
content << footer_for_department(department)
298-
file_name = "#{docs_path}/#{department_to_basename(department)}.adoc"
299+
file_name = "#{docs_path}#{department_to_basename(department)}.adoc"
299300
File.open(file_name, 'w') do |file|
300301
puts "* generated #{file_name}"
301302
file.write("#{content.strip}\n")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
require 'rubocop/cops_documentation_generator'
4+
5+
RSpec.describe CopsDocumentationGenerator, :isolated_environment do
6+
around do |example|
7+
new_global = RuboCop::Cop::Registry.new([RuboCop::Cop::Style::HashSyntax])
8+
RuboCop::Cop::Registry.with_temporary_global(new_global) { example.run }
9+
end
10+
11+
it 'generates docs without errors' do
12+
generator = described_class.new(departments: %w[Style])
13+
expect do
14+
generator.call
15+
end.to output(%r{generated .*docs/modules/ROOT/pages/cops_style.adoc}).to_stdout
16+
end
17+
end

0 commit comments

Comments
 (0)