Skip to content

Commit

Permalink
Add test by @denny
Browse files Browse the repository at this point in the history
  • Loading branch information
etagwerker committed Mar 2, 2024
1 parent 9b8cddf commit a080fb3
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions test/lib/rubycritic/generators/html_report_test.rb
Expand Up @@ -3,7 +3,6 @@
require 'test_helper'
require 'rubycritic/analysers_runner'
require 'rubycritic/generators/html_report'
require 'rubycritic/browser'
require 'fakefs_helper'

describe RubyCritic::Generator::HtmlReport do
Expand All @@ -14,26 +13,28 @@
end
end

context 'when base branch does not contain the compared file' do
it 'still works' do
create_analysed_modules_collection
it 'creates the HTML report files' do
sample_files = Dir['test/samples/**/*.rb']
create_analysed_modules_collection
generate_report

generate_report
assert File.file? 'test/samples/overview.html'
overview = File.read 'test/samples/overview.html'

assert_match overview, '<title>Ruby Critic - Home</title>'
assert File.file? 'test/samples/code_index.html'
code_index = File.read 'test/samples/code_index.html'

sample_files.each do |filename|
assert_match code_index, filename.sub('.rb', '.html')
end
end
end

def create_analysed_modules_collection
RubyCritic::Config.set(root: 'test/samples')
RubyCritic::Config.base_root_directory = 'test/samples'
RubyCritic::Config.feature_root_directory = 'test/samples'
RubyCritic::Config.compare_root_directory = 'test/samples'
RubyCritic::Config.root = 'test/samples'
RubyCritic::Config.source_control_system = RubyCritic::SourceControlSystem::Git.new
base_branch_collection = RubyCritic::AnalysedModulesCollection.new(['test/sample/base_branch_file.rb'])
RubyCritic::Config.base_branch_collection = base_branch_collection
RubyCritic::Config.mode = :compare_branches

analyser_runner = RubyCritic::AnalysersRunner.new('test/samples/feature_branch_file.rb')
analyser_runner = RubyCritic::AnalysersRunner.new('test/samples/')
@analysed_modules_collection = analyser_runner.run
end

Expand Down

0 comments on commit a080fb3

Please sign in to comment.