Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
Add support for reporting on multiple assertions in a test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJefe committed May 3, 2016
1 parent aa15113 commit f8fedd0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
5 changes: 5 additions & 0 deletions lib/compatriot/assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
module Compatriot
module Assertions
def assert_no_ui_changes(title = '')
class << self
attr_accessor :compatriot_assertion_titles
end
self.compatriot_assertion_titles ||= []
self.compatriot_assertion_titles << title
diff = Compatriot.percentage_changed(self, title)
diff_file = Compatriot.filepath_for_screenshot('diffs', Compatriot.filename_for_test(self, title))
puts "% diff is #{diff}. #{diff_file}" if Compatriot.show_diffs
Expand Down
33 changes: 20 additions & 13 deletions lib/compatriot/report_template.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
img {
width: 100%;
height: auto;
}
}
label.bold{
font-weight: bold;
}
label.collapse{
cursor: pointer;
display: block;
Expand All @@ -24,15 +27,19 @@

%h1 Compatriot Test Report
- $tests.each_with_index do |test,i|
%label.collapse{ for: "_#{i}", class: ("failed" unless test.passed?) }= test.name
%input{id: "_#{i}", type: "checkbox"}
%div
%table
%tbody
%tr
%td
%img{src: Compatriot.filepath_for_screenshot('control', Compatriot.filename_for_test(test, ''))} control
%td
%img{src: Compatriot.filepath_for_screenshot('variable', Compatriot.filename_for_test(test, ''))} variable
%td
%img{src: Compatriot.filepath_for_screenshot('diffs', Compatriot.filename_for_test(test, ''))} diff
- test.compatriot_assertion_titles.each_with_index do |title,j|
%label.collapse{ for: "_#{i}.#{j}", class: ("failed" unless test.passed?) }= test.location + ":" + title
%input{id: "_#{i}.#{j}", type: "checkbox"}
%div
%table
%tbody
%tr
%td
%label.bold Control
%img{src: Compatriot.filepath_for_screenshot('control', Compatriot.filename_for_test(test, title))}
%td
%label.bold Variable
%img{src: Compatriot.filepath_for_screenshot('variable', Compatriot.filename_for_test(test, title))}
%td
%label.bold Diff
%img{src: Compatriot.filepath_for_screenshot('diffs', Compatriot.filename_for_test(test, title))}

0 comments on commit f8fedd0

Please sign in to comment.