goggles 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b8a91f4529abbd086e9e4a3e156549a3494d75b
4
- data.tar.gz: b3a5aca11025edd9d6e17e8d25f12efaabd791f4
3
+ metadata.gz: b7191925cf0b72ef1e287a2f9f5d3206c7206763
4
+ data.tar.gz: af89e5f439fa552780efd31f1aea1a8f19286707
5
5
  SHA512:
6
- metadata.gz: 0d1962ae700d9681afff49b1aa64ac6c5389c1579b13bda95e00ffe3adb98e5c16413210a1b961972c5196525f0e2d4a139192aa18260aebebf64c759a7e8c10
7
- data.tar.gz: 28ba4feca15756f1adb1e8b1959eb09a02f43efa9936f8c248589fce7ee431fff8213c1eb6bbfdcb2564c14cd7b47d7e9928dcee7e35c9398284107896e676d9
6
+ metadata.gz: c4be6b93b9fac5088771f6329143d4b282e5252690929664639f44d6db4938e1204552aaaea93f80ee832abf03ff9e153ca4b043d5e1fd030be00c8cc83a6621
7
+ data.tar.gz: 17fa964ae31c6a90fed3fcdf6f4bfadf46fe6f6233bf90b59429a9f06695223888f9d0470d121164c88fddd157f3debaa56a2d5bf712f8ecd5607d92e099b0af
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.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johnson Denen
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: watir-webdriver
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,27 +114,7 @@ email:
100
114
  executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []
103
- files:
104
- - .gitignore
105
- - CHANGELOG.md
106
- - Gemfile
107
- - LICENSE.txt
108
- - README.md
109
- - Rakefile
110
- - features/goggles.feature
111
- - features/step_definitions/goggles_steps.rb
112
- - features/support/env.rb
113
- - goggles.gemspec
114
- - lib/goggles.rb
115
- - lib/goggles/comparison.rb
116
- - lib/goggles/configuration.rb
117
- - lib/goggles/iteration.rb
118
- - lib/goggles/version.rb
119
- - spec/goggles/comparison_spec.rb
120
- - spec/goggles/configuration_spec.rb
121
- - spec/goggles/iteration_spec.rb
122
- - spec/goggles_spec.rb
123
- - spec/spec_helper.rb
117
+ files: []
124
118
  homepage: http://github.com/jdenen/goggles
125
119
  licenses:
126
120
  - MIT
@@ -145,13 +139,5 @@ rubygems_version: 2.0.14
145
139
  signing_key:
146
140
  specification_version: 4
147
141
  summary: Compare screenshots in different browsers at different sizes
148
- test_files:
149
- - features/goggles.feature
150
- - features/step_definitions/goggles_steps.rb
151
- - features/support/env.rb
152
- - spec/goggles/comparison_spec.rb
153
- - spec/goggles/configuration_spec.rb
154
- - spec/goggles/iteration_spec.rb
155
- - spec/goggles_spec.rb
156
- - spec/spec_helper.rb
142
+ test_files: []
157
143
  has_rdoc:
data/.gitignore DELETED
@@ -1,20 +0,0 @@
1
- *.gem
2
- *.rbc
3
- *.png
4
- *_data.txt
5
- .bundle
6
- .config
7
- .yardoc
8
- Gemfile.lock
9
- InstalledFiles
10
- _yardoc
11
- coverage
12
- doc/
13
- lib/bundler/man
14
- pkg
15
- rdoc
16
- spec/reports
17
- test/tmp
18
- test/version_tmp
19
- tmp
20
- empty_config.yml
@@ -1,40 +0,0 @@
1
- # CHANGELOG
2
-
3
- ## v0.9.0 (Apr 14, 2015)
4
- * `Goggles.each` accepts Array, Integer, String, and Symbol arguments.
5
- * Arguments passed to `Goggles.each` extend configured settings instead of replacing them.
6
- * Add Cucumber tests.
7
-
8
- ## v0.8.2 (Apr 10, 2015)
9
- * Fix another typo in the gem description.
10
-
11
- ## v0.8.1 (Apr 10, 2015)
12
- * Fix typo in gem description.
13
-
14
- ## v0.8.0 (Apr 10, 2015)
15
- * Remove `swim` executable.
16
- * Remove YAML configuration.
17
- * Add `Goggles.configure` for configuration through a block (like RSpec).
18
- * Remove reserved instance variables like `@gg_url`.
19
- * Scripts are executed via blocks passed to `Goggles.each`.
20
- * `Goggles.each` yields a browser instance with the `#grab_screenshot` method.
21
- * README updates.
22
- * Add this CHANGELOG.
23
-
24
- ## v0.1.4 (Jan 28, 2014)
25
- * Small code enhancements with no user impact.
26
-
27
- ## v0.1.3 (Jan 23, 2014)
28
- * Do not delete cookies before each script.
29
- * Make `@gg_url` variable available to scripts.
30
-
31
- ## v0.1.2 (Jan 21, 2014)
32
- * Add diff color configuration setting.
33
- * Default color setting to blue.
34
- * Prepend all instance variables with `gg_`.
35
-
36
- ## v0.1.1 (Jan 20, 2014)
37
- * Add command line option for generating default project
38
-
39
- ## v0.1.0 (Jan 20, 2014)
40
- * Initial release
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in goggles.gemspec
4
- gemspec
@@ -1,22 +0,0 @@
1
- Copyright (c) 2014 Johnson Denen
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,145 +0,0 @@
1
- # goggles
2
- [![Gem Version](https://badge.fury.io/rb/goggles.png)](http://badge.fury.io/rb/goggles)
3
-
4
- Goggles is a visual testing tool inspired by [wraith](http://github.com/bbc-news/wraith) and powered by [watir-webdriver](http://github.com/watir/watir-webdriver). It compares screenshots of your web applications in different browsers at differents sizes.
5
-
6
- ## Usage
7
-
8
- ### Configuration
9
-
10
- Configure Goggles with a block passed to the `Goggles.configure` method, which will yield a config object to your block for manipulation. The `directory` setting must be configured for Goggles to work. You'll also need to provide `browsers` and `sizes` that you'd like to compare, but those can be configured with the script.
11
-
12
- The `fuzzing` and `color` attributes default to "blue" and "20%" respectively.
13
-
14
- ```ruby
15
- Goggles.configure do |config|
16
- config.directory = "/path/to/my/results"
17
- config.browsers = [:chrome, :firefox, :phantomjs]
18
- config.sizes = [1080, 600]
19
- config.color = "red"
20
- end
21
- ```
22
-
23
- ### Scripting
24
-
25
- Your Scripts are passed to `Goggles.each` as blocks. Goggles will iterate over the block with each combination of browser/browser size configured, and the method will yield a browser object to your script block.
26
-
27
- ```ruby
28
- Goggles.each do |browser|
29
- browser.goto "http://www.google.com"
30
- browser.text_field(id: "lst-ib").value = "Google"
31
- end
32
- ```
33
-
34
- #### Browsers and sizes
35
-
36
- You can pass additional browsers or browser sizes to `Goggles.each` as arrays. With version 0.8.0, these arguments will overwrite what you've configured through `Goggles.configure`.
37
-
38
- ```ruby
39
- Goggles.each([:chrome, :firefox], [1080]) do |browser|
40
- # ...
41
- end
42
- ```
43
-
44
- #### Screenshots
45
-
46
- Your script blocks should include the `Watir::Browser#grab_screenshot` method, which has been patched onto the browser objects yielded to your blocks. Simply give the method a description argument and the screenshot will be saved to your configured directory.
47
-
48
- ```ruby
49
- Goggles.each do |browser|
50
- browser.goto "http://www.google.com"
51
- browser.grab_screenshot "homepage"
52
- end
53
- ```
54
-
55
- #### Closing the browser
56
-
57
- There's no need to explicitly close the browser objects in your script blocks. Goggles will handle that.
58
-
59
- #### Results
60
-
61
- Screenshots are saved to your configured directory. Screenshot comparison results are saved to a sub-folder based on the screenshot description and browser size. Results include a diff image and data file.
62
-
63
- ```ruby
64
- Goggles.configure do |c|
65
- c.directory = "/goggles/results"
66
- c.browsers = [:chrome, :firefox, :phantomjs]
67
- c.sizes = [1080, 600]
68
- end
69
-
70
- Goggles.each do |browser|
71
- browser.goto "http://www.google.com"
72
- browser.grab_screenshot "google"
73
- end
74
- ```
75
-
76
-
77
- ```
78
- /goggles/results
79
- |- google_1080_chrome.png
80
- |- google_1080_firefox.png
81
- |- google_1080_phantomjs.png
82
- |- google_600_chrome.png
83
- |- google_600_firefox.png
84
- |- google_600_phantomjs.png
85
- |- /google_1080
86
- |- chrome_firefox_data.txt
87
- |- chrome_firefox_diff.png
88
- |- chrome_phantomjs_data.txt
89
- |- chrome_phantomjs_diff.png
90
- |- firefox_phantomjs_data.txt
91
- |- firefox_phantomjs_diff.png
92
- |- /google_600
93
- |- chrome_firefox_data.txt
94
- |- chrome_firefox_diff.png
95
- |- chrome_phantomjs_data.txt
96
- |- chrome_phantomjs_diff.png
97
- |- firefox_phantomjs_data.txt
98
- |- firefox_phantomjs_diff.png
99
- ```
100
-
101
- ## Road to 1.0.0
102
-
103
- I've made a lot of changes recently and bumped the version up to 0.8.0. Check the [CHANGELOG](CHANGELOG.md) for more information about those changes.
104
-
105
- ### v0.9.0
106
-
107
- * Browser/size arguments against `Goggles.each` extend configuration instead of overwriting it.
108
- * End-to-end Cucumber tests
109
-
110
- ### v1.0.0
111
-
112
- * Documentation
113
- * Examples
114
- * TravisCI integration for specs (but not features)
115
-
116
- ## Installation
117
-
118
- Install ImageMagick:
119
-
120
- * OSX: `$ brew install imagemagick`
121
- * Ubuntu: `$ sudo apt-get install imagemagick`
122
- * Windows: [Download](http://www.imagemagick.org/script/binary-releases.php#windows) installer and add to your PATH.
123
-
124
- Add this line to your application's Gemfile:
125
-
126
- gem 'goggles'
127
-
128
- And then execute:
129
-
130
- $ bundle
131
-
132
- Or install it yourself with:
133
-
134
- $ gem install goggles
135
-
136
- ## Contributing
137
-
138
- 1. Fork it ( http://github.com/jdenen/goggles/fork )
139
- 2. Create your feature branch (`git checkout -b my-new-feature`)
140
- 3. Commit your changes (`git commit -am 'Add some feature'`)
141
- 4. Push to the branch (`git push origin my-new-feature`)
142
- 5. Create new Pull Request
143
-
144
- ## Questions, Comments, Concerns
145
- Find me on Twitter ([@jpdenen](http://twitter.com/jpdenen)) or write up an issue.
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,23 +0,0 @@
1
- Feature: Screenshot comparison
2
- As a software professional
3
- I want to automate the collection and comparison of screenshots on my application
4
- So I can efficiently assess visual regression
5
-
6
- Background:
7
- Given I have configured Goggles with a valid directory
8
- Given I have configured Goggles for browsers at 1080 width
9
-
10
- Scenario: Compare screenshots in two browsers at one size
11
- When I use the description "search-home" in my script
12
- Then I have a file called "search-home_1080/chrome_firefox_diff.png"
13
- And I have a file called "search-home_1080/chrome_firefox_data.txt"
14
-
15
- Scenario: Extending a script with more browsers and sizes
16
- When I extend configuration with arguments "phantomjs, 500"
17
- And I use the description "homepage" in my script
18
- Then I have a file called "homepage_1080/chrome_firefox_diff.png"
19
- And I have a file called "homepage_1080/chrome_firefox_data.txt"
20
- And I have a file called "homepage_1080/chrome_phantomjs_diff.png"
21
- And I have a file called "homepage_1080/chrome_phantomjs_data.txt"
22
- And I have a file called "homepage_1080/firefox_phantomjs_diff.png"
23
- And I have a file called "homepage_1080/firefox_phantomjs_data.txt"
@@ -1,27 +0,0 @@
1
- Given /^I have configured Goggles with a valid directory$/ do
2
- @results = Pathname.new("./results").realdirpath.to_s
3
- Goggles.configure { |c| c.directory = @results }
4
- end
5
-
6
- Given /^I have configured Goggles for browsers at (\d+) width$/ do |width|
7
- Goggles.configure do |c|
8
- c.browsers = [:chrome, :firefox]
9
- c.sizes = [width]
10
- end
11
- end
12
-
13
- When /^I extend configuration with arguments "(.*)"$/ do |args|
14
- @args = args.split(/,/).map(&:strip)
15
- end
16
-
17
- When /^I use the description "(.*)" in my script$/ do |desc|
18
- Goggles.each(@args) do |browser|
19
- browser.goto "http://google.com"
20
- browser.grab_screenshot desc
21
- end
22
- end
23
-
24
- Then /^I have a file called "(.*)"$/ do |file|
25
- filepath = "#{@results}/#{file}"
26
- File.exists? filepath
27
- end
@@ -1,5 +0,0 @@
1
- require "goggles"
2
-
3
- After do
4
- FileUtils.rm_rf @results
5
- end
@@ -1,27 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'goggles/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "goggles"
8
- spec.version = Goggles::VERSION
9
- spec.authors = ["Johnson Denen"]
10
- spec.email = ["johnson.denen@gmail.com"]
11
- spec.summary = %q{Compare screenshots in different browsers at different sizes}
12
- spec.description = %q{Compare screenshots in different browsers at different sizes}
13
- spec.homepage = "http://github.com/jdenen/goggles"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
19
-
20
- spec.add_development_dependency "bundler", "~> 1.5"
21
- spec.add_development_dependency "rake"
22
- spec.add_development_dependency "rspec"
23
- spec.add_development_dependency "cucumber"
24
-
25
- spec.add_runtime_dependency "watir-webdriver"
26
- spec.add_runtime_dependency "image_size"
27
- end
@@ -1,30 +0,0 @@
1
- require "goggles/configuration"
2
- require "goggles/comparison"
3
- require "goggles/iteration"
4
-
5
- module Goggles
6
- extend self
7
-
8
- def configure &block
9
- configuration.tap { |conf| yield conf }
10
- end
11
-
12
- def each *instance, &block
13
- args = instance.flatten.map(&:to_s)
14
-
15
- sizes = configuration.sizes + args.grep(/\d+/).map(&:to_i)
16
- browsers = configuration.browsers + args.grep(/[^\d+]/).map(&:to_sym)
17
-
18
- browsers.product(sizes).each do |browser, size|
19
- Iteration.new browser, size, configuration, &block
20
- end
21
-
22
- Comparison.new(configuration).tap { |comparison| comparison.make! }
23
- end
24
-
25
- private
26
-
27
- def configuration
28
- @configuration ||= Configuration.new
29
- end
30
- end
@@ -1,84 +0,0 @@
1
- require "image_size"
2
-
3
- module Goggles
4
- class Comparison
5
- attr_reader :directory, :fuzzing, :color, :groups, :results_dir
6
-
7
- def initialize config
8
- @directory = config.directory
9
- @fuzzing = config.fuzzing
10
- @color = config.color
11
- @groups = config.groups
12
- end
13
-
14
- def make!
15
- cut_to_common_size
16
- highlight_differences
17
- end
18
-
19
- def cut_to_common_size
20
- groups.each_with_object([]) do |group, sizes|
21
- collection = find_comparable group
22
-
23
- collection.each do |img|
24
- File.open(img, 'rb'){ |file| sizes << read_size(file) }
25
- end
26
-
27
- cut! collection, sizes
28
- end
29
- end
30
-
31
- def highlight_differences
32
- groups.each do |desc|
33
- ensure_result_directory desc
34
- find_comparable(desc).combination(2).to_a.each { |imgs| diff imgs[0], imgs[1] }
35
- end
36
- end
37
-
38
- def find_comparable description
39
- Dir.glob("#{directory}/*.png").grep(/#{description}_/).sort
40
- end
41
-
42
- def find_common_width array
43
- array.collect(&:first).sort.first
44
- end
45
-
46
- def find_common_height array
47
- array.collect(&:last).sort.first
48
- end
49
-
50
- private
51
-
52
- attr_writer :results_dir
53
-
54
- def cut! images, sizes
55
- w = find_common_width sizes
56
- h = find_common_height sizes
57
- images.each { |img| `convert #{img} -background none -extent #{w}x#{h} #{img}` }
58
- end
59
-
60
- def diff img_one, img_two
61
- b1 = diffed img_one
62
- b2 = diffed img_two
63
-
64
- fuzz = "#{results_dir}/#{b1}_#{b2}_diff.png"
65
- data = "#{results_dir}/#{b1}_#{b2}_data.txt"
66
-
67
- `compare -fuzz #{fuzzing} -metric AE -highlight-color #{color} #{img_one} #{img_two} #{fuzz} 2>#{data}`
68
- end
69
-
70
- def diffed img
71
- File.basename(img).match(/\d+_(.*)\.png/)[1]
72
- end
73
-
74
- def read_size file
75
- ImageSize.new(file.read).size
76
- end
77
-
78
- def ensure_result_directory description
79
- self.results_dir = "#{directory}/#{description}"
80
- FileUtils.rm_rf results_dir
81
- FileUtils.mkdir_p results_dir
82
- end
83
- end
84
- end
@@ -1,20 +0,0 @@
1
- module Goggles
2
- class Configuration
3
- attr_accessor :browsers, :sizes, :fuzzing, :color, :groups
4
- attr_reader :directory
5
-
6
- def initialize
7
- @browsers = []
8
- @sizes = []
9
- @groups = []
10
- @directory = ""
11
- @color = "blue"
12
- @fuzzing = "20%"
13
- end
14
-
15
- def directory=(path)
16
- @directory = path
17
- FileUtils.mkdir_p path unless path.empty?
18
- end
19
- end
20
- end
@@ -1,38 +0,0 @@
1
- require "watir-webdriver"
2
-
3
- module Watir
4
- class Browser
5
- attr_accessor :goggles, :iteration
6
-
7
- def grab_screenshot name
8
- description = "#{name}_#{iteration.size}"
9
- goggles.groups << description unless goggles.groups.include? description
10
- screenshot.save "#{goggles.directory}/#{description}_#{iteration.browser_name}.png"
11
- end
12
- end
13
- end
14
-
15
- module Goggles
16
- class Iteration
17
- attr_reader :browser, :browser_name, :size, :config
18
-
19
- def initialize driver, width, config, &block
20
- @browser_name = driver
21
- @config = config
22
- @size = width
23
- build_browser
24
- yield browser
25
- browser.close
26
- end
27
-
28
- private
29
-
30
- def build_browser
31
- @browser = Watir::Browser.new(browser_name).tap do |engine|
32
- engine.goggles = config
33
- engine.iteration = self
34
- engine.driver.manage.window.resize_to size, 768
35
- end
36
- end
37
- end
38
- end
@@ -1,3 +0,0 @@
1
- module Goggles
2
- VERSION = "0.9.0"
3
- end
@@ -1,99 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Goggles::Comparison do
4
- let(:config){ instance_double "configuration" }
5
- let(:comparison){ Goggles::Comparison.new config }
6
-
7
- before do
8
- allow(config).to receive_messages(
9
- directory: "dir",
10
- fuzzing: "20%",
11
- color: "blue",
12
- groups: [1])
13
- end
14
-
15
- it "reads attributes from a given configuration object" do
16
- expect(config).to receive(:directory)
17
- expect(config).to receive(:fuzzing)
18
- expect(config).to receive(:color)
19
- Goggles::Comparison.new config
20
- end
21
-
22
- describe "#make!" do
23
- it "cuts images and highlights their differences" do
24
- expect(comparison).to receive(:cut_to_common_size)
25
- expect(comparison).to receive(:highlight_differences)
26
- comparison.make!
27
- end
28
- end
29
-
30
- describe "#cut_to_common_size" do
31
- it "iterates over screenshot descriptions" do
32
- groups = instance_double "[groups]"
33
- expect(comparison).to receive(:groups).and_return groups
34
- expect(groups).to receive(:each_with_object).with([])
35
- comparison.cut_to_common_size
36
- end
37
-
38
- it "collects comparable screenshots" do
39
- expect(comparison).to receive(:groups).and_return [1, 2]
40
- expect(comparison).to receive(:find_comparable).with(1).and_return([])
41
- expect(comparison).to receive(:find_comparable).with(2).and_return([])
42
- comparison.cut_to_common_size
43
- end
44
-
45
- context "with collection of comparable screenshots" do
46
- it "iterates over the collection" do
47
- screens = instance_double "[screenshots]"
48
- expect(comparison).to receive(:groups).and_return ["foo"]
49
- expect(comparison).to receive(:find_comparable).and_return screens
50
- expect(screens).to receive(:each)
51
- expect(comparison).to receive(:cut!).with(screens, [])
52
- comparison.cut_to_common_size
53
- end
54
- end
55
-
56
- context "while iterating over collected comparable images" do
57
- it "opens each image in binary mode" do
58
- expect(comparison).to receive(:find_comparable).and_return [:foo]
59
- expect(File).to receive(:open).with(:foo, 'rb')
60
- expect(comparison).to receive(:cut!)
61
- comparison.cut_to_common_size
62
- end
63
- end
64
- end
65
-
66
- describe "#highlight_differences" do
67
- it "diffs every combination of comparable screenshots" do
68
- images = ["foo_1.png", "foo_2.png", "foo_3.png"]
69
- expect(comparison).to receive(:groups).and_return ["foo"]
70
- expect(comparison).to receive(:find_comparable).with("foo").and_return images
71
- images.combination(2).to_a.each do |i|
72
- expect(comparison).to receive(:diff).with i[0], i[1]
73
- end
74
- comparison.highlight_differences
75
- end
76
- end
77
-
78
- describe "#find_comparable" do
79
- it "returns an array of file paths" do
80
- array = ["/foo_chrome.png", "/bar_chrome.png", "/foo_ff.png", "/bar_ff.png"]
81
- expect(Dir).to receive(:glob).and_return array
82
- expect(comparison.find_comparable "foo").to eq ["/foo_chrome.png", "/foo_ff.png"]
83
- end
84
- end
85
-
86
- describe "#find_common_width" do
87
- it "returns the smallest number from first items in an array of arrays" do
88
- arrays = [[100,40], [68,300], [104,98]]
89
- expect(comparison.find_common_width arrays).to eq 68
90
- end
91
- end
92
-
93
- describe "#find_common_height" do
94
- it "returns the smallest number from second items in an array of arrays" do
95
- arrays = [[100,40], [68,300], [104,98]]
96
- expect(comparison.find_common_height arrays).to eq 40
97
- end
98
- end
99
- end
@@ -1,47 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Goggles::Configuration do
4
- let(:config) { Goggles::Configuration.new }
5
-
6
- it "has attributes by default" do
7
- expect(config).to have_attributes(
8
- :browsers => [],
9
- :sizes => [],
10
- :groups => [],
11
- :directory => "",
12
- :color => "blue",
13
- :fuzzing => "20%"
14
- )
15
- end
16
-
17
- it "has attributes that can be set" do
18
- config.browsers << "chrome"
19
- config.sizes << 100
20
- config.groups << "foo"
21
- config.color = "red"
22
- config.fuzzing = "10%"
23
-
24
- expect(config).to have_attributes(
25
- :browsers => ["chrome"],
26
- :sizes => [100],
27
- :groups => ["foo"],
28
- :color => "red",
29
- :fuzzing => "10%"
30
- )
31
- end
32
-
33
- describe "#directory=" do
34
- it "ensures the directory exists" do
35
- expect(FileUtils).to receive(:mkdir_p).with "/foo/bar"
36
- config.directory = "/foo/bar"
37
- expect(config.directory).to eq "/foo/bar"
38
- end
39
-
40
- context "when attribute is empty" do
41
- it "does not create the directory" do
42
- expect(FileUtils).to_not receive(:mkdir_p)
43
- config.directory = ""
44
- end
45
- end
46
- end
47
- end
@@ -1,32 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Goggles::Iteration do
4
- let(:watir) { instance_double("browser") }
5
-
6
- before do
7
- allow(watir).to receive_messages(
8
- :driver => watir,
9
- :manage => watir,
10
- :window => watir,
11
- :goggles= => nil,
12
- :iteration= => nil,
13
- :resize_to => nil,
14
- :close => nil)
15
- end
16
-
17
- it "yields an instantiated browser" do
18
- expect(Watir::Browser).to receive(:new).and_return watir
19
- expect { |b| Goggles::Iteration.new "", "", "", &b }.to yield_with_args watir
20
- end
21
-
22
- it "yields the browser based on the browser_name attribute" do
23
- expect(Watir::Browser).to receive(:new).with(:foo).and_return watir
24
- Goggles::Iteration.new(:foo, "", ""){ "bar" }
25
- end
26
-
27
- it "resizes the browser based on the size attribute" do
28
- expect(Watir::Browser).to receive(:new).with(:foo).and_return watir
29
- expect(watir).to receive(:resize_to).with(500, 768)
30
- Goggles::Iteration.new(:foo, 500, ""){ "bar" }
31
- end
32
- end
@@ -1,115 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Goggles do
4
- before { allow(FileUtils).to receive(:mkdir_p) }
5
-
6
- describe ".configure" do
7
- it "yields a configuration object" do
8
- expect { |b| Goggles.configure &b }.to yield_with_args Goggles::Configuration
9
- end
10
-
11
- it "returns a configuration object" do
12
- expect(Goggles.configure { "foo" }).to be_a Goggles::Configuration
13
- end
14
-
15
- it "memoizes the configuration object" do
16
- expect(Goggles.configure { "foo" }).to equal Goggles.configure { "bar" }
17
- end
18
- end
19
-
20
- describe ".each" do
21
- let(:config) do
22
- Goggles.configure do |conf|
23
- conf.browsers = [:foo]
24
- conf.sizes = [500]
25
- end
26
- end
27
-
28
- before do
29
- allow(config).to receive_messages(directory: "/dir", fuzzing: "20%", color: "blue", groups: [])
30
- end
31
-
32
- it "passes browser, width, and configuration to an iteration object" do
33
- expect(Goggles::Iteration).to receive(:new).with(:foo, 500, config)
34
- Goggles.each { "foo" }
35
- end
36
-
37
- context "when given a browser argument" do
38
- it "extends the configured browser list with the given browser" do
39
- expect(Goggles::Iteration).to receive(:new).with(:foo, 500, config)
40
- expect(Goggles::Iteration).to receive(:new).with(:bar, 500, config)
41
- Goggles.each(:bar) { "foo" }
42
- end
43
- end
44
-
45
- context "when given a size argument" do
46
- it "extends the configured size list with the given size" do
47
- expect(Goggles::Iteration).to receive(:new).with(:foo, 500, config)
48
- expect(Goggles::Iteration).to receive(:new).with(:foo, 250, config)
49
- Goggles.each(250) { "foo" }
50
- end
51
- end
52
-
53
- context "when given multiple browser and size arguments" do
54
- it "extends the configuration with correctly" do
55
- [:foo, :bar, :baz].product([500, 1000, 250]).each do |b, s|
56
- expect(Goggles::Iteration).to receive(:new).with(b, s, config)
57
- end
58
- Goggles.each(:bar, :baz, 1000, 250) { "foo" }
59
- end
60
-
61
- context "in no particular order" do
62
- it "extends the configuration with the correct arguments" do
63
- [:foo, :bar, :baz].product([500, 1000, 250]).each do |b, s|
64
- expect(Goggles::Iteration).to receive(:new).with(b, s, config)
65
- end
66
- Goggles.each(1000, :bar, :baz, 250) { "foo" }
67
- end
68
- end
69
- end
70
-
71
- context "when given arguments in arrays" do
72
- it "extends the configuration correctly" do
73
- [:foo, :bar, :baz].product([500, 1000, 250]).each do |b, s|
74
- expect(Goggles::Iteration).to receive(:new).with(b, s, config)
75
- end
76
- Goggles.each([:bar, :baz], [250, 1000]) { "foo" }
77
- end
78
- end
79
-
80
- context "when given arguments of various classes" do
81
- it "extends the configuration correctly" do
82
- [:foo, :bar, :baz].product([500, 1000, 250]).each do |b, s|
83
- expect(Goggles::Iteration).to receive(:new).with(b, s, config)
84
- end
85
- Goggles.each([:bar, "baz"], 250, "1000") { "foo" }
86
- end
87
- end
88
-
89
- it "returns a comparison object" do
90
- expect(Goggles::Iteration).to receive(:new).with(:foo, 500, config)
91
- expect(Goggles.each { "foo" }).to be_a Goggles::Comparison
92
- end
93
-
94
- context "when configured for browsers at one size" do
95
- it "creates an iteration for each browser with the width" do
96
- config.browsers << :bar
97
- [:foo, :bar].each { |browser| expect(Goggles::Iteration).to receive(:new).with browser, 500, config }
98
- Goggles.each { "foo" }
99
- end
100
- end
101
-
102
- context "when configured for browsers at different sizes" do
103
- it "creates an iteration for every browser and width combination" do
104
- config.browsers << :bar
105
- config.sizes << 1000
106
-
107
- [:foo, :bar].product([500, 1000]).each do |browser, width|
108
- expect(Goggles::Iteration).to receive(:new).with browser, width, Object
109
- end
110
-
111
- Goggles.each { "foo" }
112
- end
113
- end
114
- end
115
- end
@@ -1,2 +0,0 @@
1
- require "goggles"
2
-