5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/compatriot/assertions.rb', line 5
def assert_no_ui_changes(title = '')
class << self
attr_accessor :compatriot_assertion_titles
attr_accessor :compatriot_percentages_changed
end
self.compatriot_assertion_titles ||= []
self.compatriot_assertion_titles << title
self.compatriot_percentages_changed ||= []
diff_file = Compatriot.filepath_for_screenshot('diffs', Compatriot.filename_for_test(self, title))
diff = Compatriot.percentage_changed(self, title)
puts "% diff is #{diff}. #{diff_file}" if Compatriot.show_diffs
pass = diff <= Compatriot.ui_difference_threshold
unless pass
puts "Found a difference, retrying once"
sleep 1
diff = Compatriot.percentage_changed(self, title)
puts "% diff is #{diff}. #{diff_file}" if Compatriot.show_diffs
pass = diff <= Compatriot.ui_difference_threshold
end
self.compatriot_percentages_changed << diff
assert pass, "The difference in the page (#{diff}%) is greater then the threshold #{Compatriot.ui_difference_threshold}"
end
|