goggles 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +4 -0
- data/lib/goggles.rb +19 -18
- data/lib/goggles/cli.rb +2 -1
- data/lib/goggles/comparison.rb +4 -4
- data/lib/goggles/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -9,6 +9,7 @@ Install ImageMagick:
|
|
9
9
|
|
10
10
|
* OSX: `$ brew install imagemagick`
|
11
11
|
* Linux: `$ sudo apt-get install imagemagick`
|
12
|
+
* Windows: [Download](http://www.imagemagick.org/script/binary-releases.php#windows) installer and add to your PATH.
|
12
13
|
|
13
14
|
Add this line to your application's Gemfile:
|
14
15
|
|
@@ -60,6 +61,9 @@ browser_widths:
|
|
60
61
|
|
61
62
|
# Fuzzing percentage. Play around with this to find the right fit. Required.
|
62
63
|
image_fuzzing: "20%"
|
64
|
+
|
65
|
+
# Color for diffing images. Defaults to blue. Optional.
|
66
|
+
diff_color: "blue"
|
63
67
|
```
|
64
68
|
|
65
69
|
If you pass scripts to goggles as part of your testing, you **must** specify when screenshots should be taken with the `#grab_screenshot` method. If you do not specify scripts in configuration, goggles will open each of your paths and take a screenshot.
|
data/lib/goggles.rb
CHANGED
@@ -13,14 +13,15 @@ module Goggles
|
|
13
13
|
def swim(config_path)
|
14
14
|
conf = YAML::load(File.open(config_path))
|
15
15
|
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
16
|
+
@gg_result_dir = conf['results_directory']
|
17
|
+
@gg_script_dir = conf['scripts_directory']
|
18
|
+
@gg_domain = conf['domain_under_test']
|
19
|
+
@gg_paths = conf['paths_to_capture']
|
20
|
+
@gg_scripts = conf['scripts_to_execute']
|
21
|
+
@gg_platforms = conf['browsers']
|
22
|
+
@gg_widths = conf['browser_widths']
|
23
|
+
@gg_fuzz = conf['image_fuzzing']
|
24
|
+
@gg_color = conf['diff_color'] || 'blue'
|
24
25
|
|
25
26
|
embark!
|
26
27
|
diff_images
|
@@ -29,7 +30,7 @@ module Goggles
|
|
29
30
|
def grab_screenshot(detail)
|
30
31
|
make_result_dir
|
31
32
|
|
32
|
-
image_dir = "#{@
|
33
|
+
image_dir = "#{@gg_result_dir}/#{@gg_label}"
|
33
34
|
image_name = "#{detail}_#{@gg_size}_#{@gg_browser}"
|
34
35
|
|
35
36
|
@watir.screenshot.save "#{image_dir}/#{image_name}.png"
|
@@ -40,25 +41,25 @@ module Goggles
|
|
40
41
|
def embark!
|
41
42
|
ensure_fresh_start
|
42
43
|
|
43
|
-
@
|
44
|
+
@gg_widths.each do |size|
|
44
45
|
@gg_size = size.to_i
|
45
46
|
|
46
|
-
@
|
47
|
+
@gg_platforms.each do |pf|
|
47
48
|
@gg_browser = pf
|
48
49
|
|
49
50
|
@watir = Watir::Browser.new pf.to_sym
|
50
51
|
@watir.driver.manage.window.resize_to(@gg_size, 768)
|
51
52
|
|
52
|
-
@
|
53
|
+
@gg_paths.each do |label, path|
|
53
54
|
@gg_label = label
|
54
|
-
url = "#{@
|
55
|
+
url = "#{@gg_domain}#{path}"
|
55
56
|
|
56
|
-
if @
|
57
|
+
if @gg_scripts.nil?
|
57
58
|
@watir.goto url
|
58
59
|
grab_screenshot("screenshot")
|
59
60
|
else
|
60
|
-
@
|
61
|
-
script = "#{@
|
61
|
+
@gg_scripts.each do |script|
|
62
|
+
script = "#{@gg_script_dir}/#{script}"
|
62
63
|
execute_script(url, script)
|
63
64
|
end
|
64
65
|
end
|
@@ -70,11 +71,11 @@ module Goggles
|
|
70
71
|
end
|
71
72
|
|
72
73
|
def ensure_fresh_start
|
73
|
-
FileUtils.rm_rf("#{@
|
74
|
+
FileUtils.rm_rf("#{@gg_result_dir}")
|
74
75
|
end
|
75
76
|
|
76
77
|
def make_result_dir
|
77
|
-
FileUtils.mkdir_p("#{@
|
78
|
+
FileUtils.mkdir_p("#{@gg_result_dir}/#{@gg_label}")
|
78
79
|
end
|
79
80
|
|
80
81
|
end
|
data/lib/goggles/cli.rb
CHANGED
data/lib/goggles/comparison.rb
CHANGED
@@ -5,9 +5,9 @@ module Goggles
|
|
5
5
|
def diff_images
|
6
6
|
size_to_smallest!
|
7
7
|
|
8
|
-
images = Dir.glob("#{@
|
8
|
+
images = Dir.glob("#{@gg_result_dir}/*/*.png").sort
|
9
9
|
|
10
|
-
raise Goggles::EmptyResultError, "No screenshots found in results directory: #{@
|
10
|
+
raise Goggles::EmptyResultError, "No screenshots found in results directory: #{@gg_result_dir}" if images.empty?
|
11
11
|
|
12
12
|
until images.empty?
|
13
13
|
one = images.slice!(0)
|
@@ -19,12 +19,12 @@ module Goggles
|
|
19
19
|
diff_out = "#{out_path}diff.png"
|
20
20
|
data_out = "#{out_path}data.txt"
|
21
21
|
|
22
|
-
`compare -fuzz #{@
|
22
|
+
`compare -fuzz #{@gg_fuzz} -metric AE -highlight-color #{@gg_color} #{one} #{two} #{diff_out} 2>#{data_out}`
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def size_to_smallest!
|
27
|
-
images = Dir.glob("#{@
|
27
|
+
images = Dir.glob("#{@gg_result_dir}/*/*.png").sort
|
28
28
|
|
29
29
|
until images.empty?
|
30
30
|
one = images.slice!(0)
|
data/lib/goggles/version.rb
CHANGED