goggles 0.8.2 → 0.9.0

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: 24f33bebed8e084b7b10246e8cb66edaf1f99538
4
- data.tar.gz: 6d6f9c067e9ca3b22a2223ef48c1b77199870827
3
+ metadata.gz: 0b8a91f4529abbd086e9e4a3e156549a3494d75b
4
+ data.tar.gz: b3a5aca11025edd9d6e17e8d25f12efaabd791f4
5
5
  SHA512:
6
- metadata.gz: a6b72602d5cff5218ce00541f5aa034189bce018722be5ef4409d5d9712ce4eba439f1f4271f1eccc341ecea01e8909c74a95ff3d7649334bd0b4d99ee71b95b
7
- data.tar.gz: a934d033c39a947d8be9195bbf954e8ea29561223fce493a39b28cc43be775f466d0aca99b2491a972c9cafb48da79163df18c75e9df3f53fbcf5a34ff384235
6
+ metadata.gz: 0d1962ae700d9681afff49b1aa64ac6c5389c1579b13bda95e00ffe3adb98e5c16413210a1b961972c5196525f0e2d4a139192aa18260aebebf64c759a7e8c10
7
+ data.tar.gz: 28ba4feca15756f1adb1e8b1959eb09a02f43efa9936f8c248589fce7ee431fff8213c1eb6bbfdcb2564c14cd7b47d7e9928dcee7e35c9398284107896e676d9
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
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
+
3
8
  ## v0.8.2 (Apr 10, 2015)
4
9
  * Fix another typo in the gem description.
5
10
 
data/README.md CHANGED
@@ -41,10 +41,6 @@ Goggles.each([:chrome, :firefox], [1080]) do |browser|
41
41
  end
42
42
  ```
43
43
 
44
- **TODO**
45
-
46
- Before the 1.0.0 release, these arguments will act as additonal browsers/sizes to script against. That way, the base configuration can be extended for particular script instances.
47
-
48
44
  #### Screenshots
49
45
 
50
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.
@@ -0,0 +1,23 @@
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"
@@ -0,0 +1,27 @@
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
@@ -0,0 +1,5 @@
1
+ require "goggles"
2
+
3
+ After do
4
+ FileUtils.rm_rf @results
5
+ end
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.add_development_dependency "bundler", "~> 1.5"
21
21
  spec.add_development_dependency "rake"
22
22
  spec.add_development_dependency "rspec"
23
+ spec.add_development_dependency "cucumber"
23
24
 
24
25
  spec.add_runtime_dependency "watir-webdriver"
25
26
  spec.add_runtime_dependency "image_size"
@@ -9,9 +9,11 @@ module Goggles
9
9
  configuration.tap { |conf| yield conf }
10
10
  end
11
11
 
12
- def each browsers = nil, sizes = nil, &block
13
- browsers ||= configuration.browsers
14
- sizes ||= configuration.sizes
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)
15
17
 
16
18
  browsers.product(sizes).each do |browser, size|
17
19
  Iteration.new browser, size, configuration, &block
@@ -1,3 +1,3 @@
1
1
  module Goggles
2
- VERSION = "0.8.2"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -34,9 +34,56 @@ describe Goggles do
34
34
  Goggles.each { "foo" }
35
35
  end
36
36
 
37
- it "accepts non-configured browser and size arguments" do
38
- expect(Goggles::Iteration).to receive(:new).with(:bar, 300, config)
39
- Goggles.each([:bar], [300]) { "foo" }
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
40
87
  end
41
88
 
42
89
  it "returns a comparison object" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goggles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johnson Denen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-10 00:00:00.000000000 Z
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: cucumber
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: watir-webdriver
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -93,6 +107,9 @@ files:
93
107
  - LICENSE.txt
94
108
  - README.md
95
109
  - Rakefile
110
+ - features/goggles.feature
111
+ - features/step_definitions/goggles_steps.rb
112
+ - features/support/env.rb
96
113
  - goggles.gemspec
97
114
  - lib/goggles.rb
98
115
  - lib/goggles/comparison.rb
@@ -129,6 +146,9 @@ signing_key:
129
146
  specification_version: 4
130
147
  summary: Compare screenshots in different browsers at different sizes
131
148
  test_files:
149
+ - features/goggles.feature
150
+ - features/step_definitions/goggles_steps.rb
151
+ - features/support/env.rb
132
152
  - spec/goggles/comparison_spec.rb
133
153
  - spec/goggles/configuration_spec.rb
134
154
  - spec/goggles/iteration_spec.rb