Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test by @denny #483

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions test/lib/rubycritic/generators/html_report_test.rb
Original file line number Diff line number Diff line change
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
Loading