class Compatriot::Reporter
Attributes
tests[RW]
Public Class Methods
new(tests)
click to toggle source
# File lib/compatriot/reporter.rb, line 7 def initialize(tests) @tests = tests end
Public Instance Methods
format(tests)
click to toggle source
# File lib/compatriot/reporter.rb, line 19 def format(tests) formated_tests = [] tests.each do |test| next unless test.respond_to? :compatriot_assertion_titles test.compatriot_assertion_titles.each_with_index do |title,j| formated_test = { label: test.location + ':' + title + ':' + test.compatriot_percentages_changed[j].to_s + "% difference", percentage_changed: test.compatriot_percentages_changed[j], status: test.passed? ? "passed" : "failed", control_image_path: Compatriot.relative_filepath_for_screenshot('control', Compatriot.filename_for_test(test, title)), variable_image_path: Compatriot.relative_filepath_for_screenshot('variable', Compatriot.filename_for_test(test, title)), diff_image_path: Compatriot.relative_filepath_for_screenshot('diffs', Compatriot.filename_for_test(test, title)), } formated_tests << formated_test end end formated_tests.sort_by { |k| k[:percentage_changed] }.reverse end
run()
click to toggle source
# File lib/compatriot/reporter.rb, line 11 def run $tests = format(tests) file_path = File.expand_path('../report_template.html.haml', __FILE__) template = File.read(file_path) engine = Haml::Engine.new(template) File.write 'compatriot_report.html',engine.render end