Module: Watirmark::Screenshot
- Defined in:
- lib/watirmark/screenshot.rb
Defined Under Namespace
Classes: Current, CurrentScreenShots, Master, MasterAlbum
Class Method Summary
collapse
Class Method Details
.compare_screenshots(masters, currents) ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/watirmark/screenshot.rb', line 12
def compare_screenshots(masters, currents)
raise ArgumentError, "Passed invalid arguments to compare_screenshots" unless masters.kind_of?(MasterAlbum) && currents.kind_of?(CurrentScreenShots)
if Watirmark::Configuration.instance.snapshotwidth.kind_of?(Fixnum)
compare_specific_screenshot_size(currents, masters)
else
compare_standard_screenshot_sizes(currents, masters)
end
end
|
.compare_specific_screenshot_size(currents, masters) ⇒ Object
22
23
24
25
26
|
# File 'lib/watirmark/screenshot.rb', line 22
def compare_specific_screenshot_size(currents, masters)
unless currents.screenshots.md5 == masters.album.md5
report_failure(currents.screenshots.filename, masters.album.filename)
end
end
|
.compare_standard_screenshot_sizes(currents, masters) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/watirmark/screenshot.rb', line 28
def compare_standard_screenshot_sizes(currents, masters)
masters.album.each_with_index do |master, index|
unless currents.screenshots[index].md5 == master.md5
report_failure(currents.screenshots[index].filename, masters.filename)
end
end
end
|
.report_failure(current, master) ⇒ Object
36
37
38
39
|
# File 'lib/watirmark/screenshot.rb', line 36
def report_failure(current, master)
Watirmark.logger.info "Checking Snapshot:\n master: #{master}\n screenshot: #{current}"
raise ArgumentError, "Master snapshot: #{File.expand_path(master)} does not match current snapshot: #{File.expand_path(current)}"
end
|