lib/rspec_tracer/html_reporter/reporter.rb in rspec-tracer-0.9.2 vs lib/rspec_tracer/html_reporter/reporter.rb in rspec-tracer-0.9.3

- old
+ new

@@ -8,22 +8,16 @@ class Reporter attr_reader :last_run, :examples, :flaky_examples, :examples_dependency, :files_dependency def initialize @reporter = RSpecTracer.runner.reporter - - format_last_run - format_examples - format_flaky_examples - format_examples_dependency - format_files_dependency end def generate_report starting = Process.clock_gettime(Process::CLOCK_MONOTONIC) - copy_assets + prepare file_name = File.join(RSpecTracer.report_path, 'index.html') File.open(file_name, 'wb') do |file| file.puts(template('layout').result(binding)) @@ -35,19 +29,30 @@ puts "RSpecTracer generated HTML report to #{file_name} (took #{elpased})" end private + def prepare + format_last_run + format_examples + format_duplicate_examples + format_flaky_examples + format_examples_dependency + format_files_dependency + copy_assets + end + def copy_assets Dir[File.join(File.dirname(__FILE__), 'public/*')].each do |path| FileUtils.cp_r(path, asset_output_path) end end def format_last_run @last_run = @reporter.last_run.slice( :actual_count, + :duplicate_examples, :failed_examples, :pending_examples, :skipped_examples ) end @@ -77,10 +82,24 @@ last_run: example_run_local_time(example[:execution_result][:finished_at]) } end end + def format_duplicate_examples + @duplicate_examples = [] + + @reporter.duplicate_examples.each_pair do |example_id, examples| + examples.each do |example| + @duplicate_examples << { + id: example_id, + description: example[:full_description], + location: example_location(example[:rerun_file_name], example[:rerun_line_number]) + } + end + end + end + def format_flaky_examples @flaky_examples = @examples.slice(*@reporter.flaky_examples).values end def example_run_local_time(utc_time) @@ -145,9 +164,17 @@ def assets_path(name) File.join('./assets', RSpecTracer::VERSION, name) end def formatted_examples(title, examples) + title_id = report_container_id(title) + current_binding = binding + + current_binding.local_variable_set(:title_id, title_id) + template(title_id).result(current_binding) + end + + def formatted_duplicate_examples(title, duplicate_examples) title_id = report_container_id(title) current_binding = binding current_binding.local_variable_set(:title_id, title_id) template(title_id).result(current_binding)