Class: Compatriot::Reporter
- Inherits:
-
Object
- Object
- Compatriot::Reporter
- Defined in:
- lib/compatriot/reporter.rb
Instance Attribute Summary collapse
-
#tests ⇒ Object
Returns the value of attribute tests.
Instance Method Summary collapse
- #format(tests) ⇒ Object
-
#initialize(tests) ⇒ Reporter
constructor
A new instance of Reporter.
- #run ⇒ Object
Constructor Details
#initialize(tests) ⇒ Reporter
Returns a new instance of Reporter.
7 8 9 |
# File 'lib/compatriot/reporter.rb', line 7 def initialize(tests) @tests = tests end |
Instance Attribute Details
#tests ⇒ Object
Returns the value of attribute tests.
5 6 7 |
# File 'lib/compatriot/reporter.rb', line 5 def tests @tests end |
Instance Method Details
#format(tests) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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 ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/compatriot/reporter.rb', line 11 def run $tests = format(tests) file_path = File.('../report_template.html.haml', __FILE__) template = File.read(file_path) engine = Haml::Engine.new(template) File.write 'compatriot_report.html',engine.render end |