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 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
- @goggles_result_dir = conf['results_directory']
17
- @goggles_script_dir = conf['scripts_directory']
18
- @goggles_domain = conf['domain_under_test']
19
- @goggles_paths = conf['paths_to_capture']
20
- @goggles_scripts = conf['scripts_to_execute']
21
- @goggles_platforms = conf['browsers']
22
- @goggles_widths = conf['browser_widths']
23
- @goggles_fuzz = conf['image_fuzzing']
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 = "#{@goggles_result_dir}/#{@gg_label}"
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
- @goggles_widths.each do |size|
44
+ @gg_widths.each do |size|
44
45
  @gg_size = size.to_i
45
46
 
46
- @goggles_platforms.each do |pf|
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
- @goggles_paths.each do |label, path|
53
+ @gg_paths.each do |label, path|
53
54
  @gg_label = label
54
- url = "#{@goggles_domain}#{path}"
55
+ url = "#{@gg_domain}#{path}"
55
56
 
56
- if @goggles_scripts.nil?
57
+ if @gg_scripts.nil?
57
58
  @watir.goto url
58
59
  grab_screenshot("screenshot")
59
60
  else
60
- @goggles_scripts.each do |script|
61
- script = "#{@goggles_script_dir}/#{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("#{@goggles_result_dir}")
74
+ FileUtils.rm_rf("#{@gg_result_dir}")
74
75
  end
75
76
 
76
77
  def make_result_dir
77
- FileUtils.mkdir_p("#{@goggles_result_dir}/#{@gg_label}")
78
+ FileUtils.mkdir_p("#{@gg_result_dir}/#{@gg_label}")
78
79
  end
79
80
 
80
81
  end
data/lib/goggles/cli.rb CHANGED
@@ -53,7 +53,8 @@ module Goggles
53
53
  'paths_to_capture' => { 'home' => "/", 'gmail' => "/gmail" },
54
54
  'browsers' => ["chrome", "firefox"],
55
55
  'browser_widths' => [1024, 600],
56
- 'image_fuzzing' => "20%"
56
+ 'image_fuzzing' => "20%",
57
+ 'diff_color' => "blue"
57
58
  }
58
59
  end
59
60
  end
@@ -5,9 +5,9 @@ module Goggles
5
5
  def diff_images
6
6
  size_to_smallest!
7
7
 
8
- images = Dir.glob("#{@goggles_result_dir}/*/*.png").sort
8
+ images = Dir.glob("#{@gg_result_dir}/*/*.png").sort
9
9
 
10
- raise Goggles::EmptyResultError, "No screenshots found in results directory: #{@goggles_result_dir}" if images.empty?
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 #{@goggles_fuzz} -metric AE -highlight-color blue #{one} #{two} #{diff_out} 2>#{data_out}`
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("#{@goggles_result_dir}/*/*.png").sort
27
+ images = Dir.glob("#{@gg_result_dir}/*/*.png").sort
28
28
 
29
29
  until images.empty?
30
30
  one = images.slice!(0)
@@ -1,3 +1,3 @@
1
1
  module Goggles
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goggles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: