lineup 0.2.1 → 0.3.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: 067fafb3cf9ae7850aa9cd76e2ab536ae3db4253
4
- data.tar.gz: b8e613c3b5802b45a0aa5e59a52b8c8a518a1547
3
+ metadata.gz: 89ea9b6e95a25a526e1bb6317ec204a8518d4e4d
4
+ data.tar.gz: 01f7795b66bb5b652c0f01925307b5fa6af6ea2e
5
5
  SHA512:
6
- metadata.gz: 8cefe37fc7a30fb1551bda59558cb536d6ddc585ff0f4df76af0d1a4538b3b80be6b1bac914ffd3b774680dc7e505749d05a2753dc448c69883423e986573ea1
7
- data.tar.gz: 5748e11a87ca7960bc73ad4458c7a6e70ad8446313657438871540aac843c53302e6dea58fcf30b179974938ed99d792817defbd8df7955b3a687d8222612c02
6
+ metadata.gz: 774b8f2777cd26e9609875e34a29336dcda9a5c254e3c78acf153a48d320b0a0587d2332c15090bdb8be10ed2daccec3c848f1fed0cbd8ccc1b662208aa5a5fb
7
+ data.tar.gz: bfd830aa1e580998ba50c87bfbea26004a76202b97e46418607de0358bb22b52827bba433ef5d3af474ce3d52f785bc447b882d4b1564b345415cb1fe7d2d5c3
data/Gemfile.lock CHANGED
@@ -2,46 +2,46 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  lineup (0.2.1)
5
- chunky_png (>= 1.3.4)
6
- dimensions (>= 1.3.0)
7
- headless (>= 0.1.1)
8
- oily_png (>= 1.2.0)
9
- pxdoppelganger (>= 0.1.1)
5
+ chunky_png (~> 1.3)
6
+ dimensions (~> 1.3)
7
+ headless (~> 0.1)
8
+ oily_png (~> 1.2)
9
+ pxdoppelganger (~> 0.1)
10
10
  rspec (~> 3.2)
11
- selenium-webdriver (>= 2.46.2)
12
- watir (>= 5.0.0)
13
- watir-webdriver (>= 0.8.0)
11
+ selenium-webdriver (~> 2.46)
12
+ watir (~> 5.0)
13
+ watir-webdriver (~> 0.8)
14
14
 
15
15
  GEM
16
16
  remote: https://rubygems.org/
17
17
  specs:
18
- childprocess (0.5.5)
18
+ childprocess (0.5.9)
19
19
  ffi (~> 1.0, >= 1.0.11)
20
- chunky_png (1.3.4)
20
+ chunky_png (1.3.5)
21
21
  commonwatir (4.0.0)
22
22
  diff-lcs (1.2.5)
23
23
  dimensions (1.3.0)
24
- ffi (1.9.6)
25
- headless (2.0.0)
26
- multi_json (1.11.0)
24
+ ffi (1.9.10)
25
+ headless (0.3.1)
26
+ multi_json (1.11.2)
27
27
  oily_png (1.2.0)
28
28
  chunky_png (~> 1.3.1)
29
29
  pxdoppelganger (0.1.1)
30
- rspec (3.2.0)
31
- rspec-core (~> 3.2.0)
32
- rspec-expectations (~> 3.2.0)
33
- rspec-mocks (~> 3.2.0)
34
- rspec-core (3.2.3)
35
- rspec-support (~> 3.2.0)
36
- rspec-expectations (3.2.1)
30
+ rspec (3.4.0)
31
+ rspec-core (~> 3.4.0)
32
+ rspec-expectations (~> 3.4.0)
33
+ rspec-mocks (~> 3.4.0)
34
+ rspec-core (3.4.2)
35
+ rspec-support (~> 3.4.0)
36
+ rspec-expectations (3.4.0)
37
37
  diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.2.0)
39
- rspec-mocks (3.2.1)
38
+ rspec-support (~> 3.4.0)
39
+ rspec-mocks (3.4.1)
40
40
  diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.2.0)
42
- rspec-support (3.2.2)
41
+ rspec-support (~> 3.4.0)
42
+ rspec-support (3.4.1)
43
43
  rubyzip (1.1.7)
44
- selenium-webdriver (2.46.2)
44
+ selenium-webdriver (2.50.0)
45
45
  childprocess (~> 0.5)
46
46
  multi_json (~> 1.0)
47
47
  rubyzip (~> 1.0)
@@ -49,9 +49,9 @@ GEM
49
49
  watir (5.0.0)
50
50
  commonwatir (~> 4)
51
51
  watir-webdriver
52
- watir-webdriver (0.8.0)
53
- selenium-webdriver (>= 2.45)
54
- websocket (1.2.1)
52
+ watir-webdriver (0.9.1)
53
+ selenium-webdriver (>= 2.46.2)
54
+ websocket (1.2.2)
55
55
 
56
56
  PLATFORMS
57
57
  ruby
@@ -68,4 +68,4 @@ DEPENDENCIES
68
68
  watir-webdriver
69
69
 
70
70
  BUNDLED WITH
71
- 1.10.6
71
+ 1.11.2
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Lineup
2
2
 
3
+ ![Logo](https://raw.githubusercontent.com/otto-de/lineup/master/doc/lineup_mini.png)
4
+
3
5
  Lineup is doing automated testing of webpage designs, eg. in continious delivery.
4
6
  If you push new code to production, you can evaluate the design of your page compared to a defined base design and
5
7
  get an analysis about the difference of the designs:
data/doc/lineup.png ADDED
Binary file
Binary file
@@ -7,7 +7,7 @@ require_relative '../helper'
7
7
 
8
8
  class Browser
9
9
 
10
- def initialize(baseurl, urls, resolutions, path, headless, wait)
10
+ def initialize(baseurl, urls, resolutions, path, headless, wait, cookie = false)
11
11
  @absolute_image_path = path
12
12
  FileUtils.mkdir_p @absolute_image_path
13
13
  @baseurl = baseurl
@@ -15,6 +15,7 @@ class Browser
15
15
  @resolutions = resolutions
16
16
  @headless = headless
17
17
  @wait = wait
18
+ @cookie = cookie
18
19
  end
19
20
 
20
21
  def record(version)
@@ -50,9 +51,14 @@ class Browser
50
51
  def screenshot_recorder(width, url, version)
51
52
  filename = Helper.filename(@absolute_image_path, url, width, version)
52
53
  @browser.driver.manage.window.resize_to(width, 1000)
53
- @browser.cookies.clear
54
+
54
55
  url = Helper.url(@baseurl, url)
55
56
  @browser.goto url
57
+ if @cookie
58
+ @browser.cookies.clear
59
+ @browser.cookies.add(@cookie[:name], @cookie[:value], domain: @cookie[:domain], path: @cookie[:path], expires: Time.now + 7200, secure: @cookie[:secure])
60
+ @browser.goto url
61
+ end
56
62
  sleep @wait if @wait
57
63
  @browser.screenshot.save( File.expand_path(filename))
58
64
  end
@@ -1,8 +1,8 @@
1
1
  module Lineup
2
2
  class Version
3
3
  MAJOR = 0
4
- MINOR = 2
5
- PATCH = 1
4
+ MINOR = 3
5
+ PATCH = 0
6
6
 
7
7
  class << self
8
8
  def to_s
data/lib/lineup.rb CHANGED
@@ -173,6 +173,34 @@ module Lineup
173
173
  end
174
174
 
175
175
 
176
+ def cookie_for_experiment(cookie)
177
+
178
+ # a hash for a cookie can be set here. this is optional.
179
+ #
180
+ # e.g {name: 'experiment', value: 'experiment_value', domain: 'domain.com', path: '/', expires: <Time>, secure: false}
181
+ #
182
+ # if it is not nil it has to be an array:
183
+ if cookie
184
+ # generate :symbol => "value" hash map from "symbol" => "value"
185
+ cookie = cookie.inject({}){|element,(symbol,value)| element[symbol.to_sym] = value; element}
186
+
187
+ #Validation
188
+ (raise "Cookie must be a hash of format
189
+ {name: 'experiment', value: 'experiment_value', domain: 'domain.com', path: '/', expires: <Time>, secure: false}
190
+ " unless cookie.is_a? Hash)
191
+
192
+ raise "cookie must have value for :name" unless (cookie[:name]).is_a? String
193
+ raise "cookie must have value for :value" unless (cookie[:value]).is_a? String
194
+ raise "cookie must have value for :domain" unless (cookie[:domain]).is_a? String
195
+ raise "cookie must have value for :path" unless (cookie[:path]).is_a? String
196
+ raise "cookie must have value for :secure" if (cookie[:secure]) == nil
197
+ end
198
+
199
+ # assign the variable
200
+
201
+ @cookie_for_experiment = cookie
202
+ end
203
+
176
204
 
177
205
  def wait_for_asynchron_pages(wait)
178
206
 
@@ -190,8 +218,6 @@ module Lineup
190
218
  @wait_for_asynchron_pages = wait
191
219
  end
192
220
 
193
-
194
-
195
221
  def load_json_config(path)
196
222
 
197
223
  # loads all possible configs from a json file.
@@ -209,11 +235,12 @@ module Lineup
209
235
  use_phantomjs(configuration["use_phantomjs"])
210
236
  difference_path(configuration["difference_path"])
211
237
  wait_for_asynchron_pages(configuration["wait_for_asynchron_pages"])
238
+ cookie_for_experiment(configuration["cookie_for_experiment"])
212
239
 
213
240
  # the method calls set the variables for the parameters, we return an array with all of them.
214
241
  # for the example above it is:
215
242
  # [["/multimedia", "/sport"], [600, 800, 1200], "~/images/", true, "#/images/diff"]
216
- [@urls, @resolutions, @screenshots_path, @headless, @difference_path, @wait_for_asynchron_pages]
243
+ [@urls, @resolutions, @screenshots_path, @headless, @difference_path, @wait_for_asynchron_pages, @cookie_for_experiment]
217
244
  end
218
245
 
219
246
 
@@ -230,7 +257,7 @@ module Lineup
230
257
  # and saves the screenshot in the file
231
258
  # @screenshot_path
232
259
 
233
- browser = Browser.new(@baseurl, @urls, @resolutions, @screenshots_path, @headless, @wait_for_asynchron_pages)
260
+ browser = Browser.new(@baseurl, @urls, @resolutions, @screenshots_path, @headless, @wait_for_asynchron_pages, @cookie_for_experiment)
234
261
 
235
262
  # the only argument missing is if this is the "base" or "new" screenshot, this can be
236
263
  # passed as an argument. The value does not need to be "base" or "new", but can be anything
@@ -6,7 +6,7 @@ require_relative '../../lib/lineup'
6
6
 
7
7
  describe '#screeshot_recorder' do
8
8
 
9
- BASE_URL = 'https://www.otto.de'
9
+ BASE_URL = 'https://www.google.de/'
10
10
  SCREENSHOTS = "#{Dir.pwd}/screenshots/"
11
11
 
12
12
  after(:each) { FileUtils.rmtree SCREENSHOTS }
@@ -15,7 +15,13 @@ describe '#screeshot_recorder' do
15
15
  # Given
16
16
  file = "#{Dir.pwd}/test_configuration.json"
17
17
  FileUtils.rm file if (File.exists? file)
18
- json = '{"urls":"page1, page2","resolutions":"13,42","filepath_for_images":"some/path","use_phantomjs":true,"difference_path":"some/difference/image/path", "wait_for_asynchron_pages":5}'
18
+ json = '{"urls":"page1, page2",
19
+ "resolutions":"13,42",
20
+ "filepath_for_images":"some/path",
21
+ "use_phantomjs":true,
22
+ "difference_path":"some/difference/image/path",
23
+ "wait_for_asynchron_pages":5
24
+ }'
19
25
  save_json(json, file)
20
26
 
21
27
  # When
@@ -24,7 +30,7 @@ describe '#screeshot_recorder' do
24
30
  # Then
25
31
  expect(
26
32
  lineup.load_json_config(file)
27
- ).to eq([['page1', 'page2'], [13,42], 'some/path', true, 'some/difference/image/path', 5])
33
+ ).to eq([['page1', 'page2'], [13,42], 'some/path', true, 'some/difference/image/path', 5, nil])
28
34
 
29
35
  # cleanup:
30
36
  FileUtils.rm file if (File.exists? file)
@@ -54,7 +60,7 @@ describe '#screeshot_recorder' do
54
60
 
55
61
  it 'takes a screenshot a desired resolution' do
56
62
  # Given
57
- width = '320' #min width firefox as of Sep 2015
63
+ width = '700'
58
64
  lineup = Lineup::Screenshot.new(BASE_URL)
59
65
 
60
66
  # When
@@ -74,7 +80,7 @@ describe '#screeshot_recorder' do
74
80
 
75
81
  it 'takes screenshots of different pages, if specified' do
76
82
  # Given
77
- urls = '/, multimedia, sport'
83
+ urls = '/, flights'
78
84
  lineup = Lineup::Screenshot.new(BASE_URL)
79
85
  lineup.resolutions('1180')
80
86
  lineup.urls(urls)
@@ -88,7 +94,7 @@ describe '#screeshot_recorder' do
88
94
  ).to be(true)
89
95
 
90
96
  expect(
91
- File.exist? ("#{Dir.pwd}/screenshots/multimedia_1180_base.png")
97
+ File.exist? ("#{Dir.pwd}/screenshots/flights_1180_base.png")
92
98
  ).to be(true)
93
99
 
94
100
  end
@@ -106,14 +112,22 @@ describe '#screeshot_recorder' do
106
112
 
107
113
  # Then
108
114
  }.to raise_error ArgumentError
109
-
110
115
  end
111
116
 
112
117
  it 'compares a base and a new screenshot and detects no difference if images are the same' do
113
118
  # Given
114
119
  lineup = Lineup::Screenshot.new(BASE_URL)
115
- lineup.urls('/shoppages/begood')
120
+ lineup.urls('/')
116
121
  lineup.resolutions('400')
122
+ lineup.wait_for_asynchron_pages(5)
123
+ lineup.use_phantomjs(true)
124
+ cookie = {"name" => "CONSENT",
125
+ "value" => "YES+DE.de+V7",
126
+ "domain" => ".google.de",
127
+ "path" => "/",
128
+ "secure" => false}
129
+ lineup.cookie_for_experiment(cookie)
130
+
117
131
  lineup.record_screenshot('base')
118
132
  lineup.record_screenshot('new')
119
133
 
@@ -126,11 +140,47 @@ describe '#screeshot_recorder' do
126
140
 
127
141
  end
128
142
 
143
+ it 'compares a base and a new screenshot when loading a json config and setting a cookie' do
144
+ # Given
145
+ file = "#{Dir.pwd}/test_configuration.json"
146
+ FileUtils.rm file if (File.exists? file)
147
+ json = '{"urls":"page1, page2",
148
+ "resolutions":"13,42",
149
+ "filepath_for_images":"some/path",
150
+ "use_phantomjs":true,
151
+ "difference_path":"some/difference/image/path",
152
+ "wait_for_asynchron_pages":5,
153
+ "cookie_for_experiment":{
154
+ "name":"CONSENT",
155
+ "value":"YES+DE.de+V7",
156
+ "domain":".google.de",
157
+ "path":"/",
158
+ "secure":false
159
+ }
160
+ }'
161
+ save_json(json, file)
162
+ lineup = Lineup::Screenshot.new(BASE_URL)
163
+ lineup.load_json_config(file)
164
+
165
+ lineup.record_screenshot('base')
166
+ lineup.record_screenshot('new')
167
+
168
+ expect(
169
+ # When
170
+ lineup.compare('base', 'new')
171
+
172
+ # Then
173
+ ).to eq([])
174
+
175
+ # cleanup:
176
+ FileUtils.rm file if (File.exists? file)
177
+ end
178
+
129
179
  it 'compares a base and a new screenshot and returns the difference if the images are NOT the same as json log' do
130
180
  # Given
131
- width = '600'
132
- base_site = 'multimedia'
133
- new_site = 'sport'
181
+ width = '800'
182
+ base_site = '?q=test'
183
+ new_site = '?q=somethingelse'
134
184
  json_path = "#{Dir.pwd}"
135
185
  json_file = "#{json_path}/log.json"
136
186
 
@@ -152,41 +202,38 @@ describe '#screeshot_recorder' do
152
202
  # the output will be similar to the values here:
153
203
  # [
154
204
  # {
155
- # :url => 'sport',
156
- # :width => 600,
205
+ # :url => 'translate',
206
+ # :width => 800,
157
207
  # :difference => 0.7340442722738748,
158
- # :base_file => '/home/myname/lineup/tests/respec/screenshots/sport_600_base.png'
159
- # :new_file => '/home/myname/lineup/tests/respec/screenshots/sport_600_new.png'
160
- # :diff_file => '/home/myname/lineup/tests/rspec/screenshots/sport_600_DIFFERENCE.png'
208
+ # :base_file => '/home/myname/lineup/tests/respec/screenshots/translate_600_base.png'
209
+ # :new_file => '/home/myname/lineup/tests/respec/screenshots/translate_600_new.png'
210
+ # :diff_file => '/home/myname/lineup/tests/rspec/screenshots/translate_600_DIFFERENCE.png'
161
211
  # }
162
212
  # ]
163
213
  #
164
214
  expect(
165
215
  (lineup.compare('base', 'new').first)[:url]
166
- ).to eq('sport')
216
+ ).to eq('?q=somethingelse')
167
217
  # And
168
218
  expect(
169
219
  (lineup.compare('base', 'new').first)[:width]
170
- ).to eq(600)
220
+ ).to eq(800)
171
221
  # And
172
222
  result = (lineup.compare('base', 'new').first)[:difference]
173
223
  expect(
174
224
  result
175
- ).to be_within(15).of(20) # 'compare' returns the difference of pixel between the screenshots in %
176
- # 15-20% of pixel works toady (12.3 on 2015/09) for the difference between sport and multimedia page of OTTO.de,
177
- # but the pages may some day look more or less alike, then these values can be changed
178
- # And
225
+ ).to be > 0 # 'compare' returns the difference of pixel between the screenshots in %
179
226
  expect(
180
227
  (lineup.compare('base', 'new').first)[:base_file]
181
- ).to include("/lineup/tests/rspec/screenshots/sport_600_base.png")
228
+ ).to include("/lineup/tests/rspec/screenshots/?q=somethingelse_#{width}_base.png")
182
229
  # And
183
230
  expect(
184
231
  (lineup.compare('base', 'new').first)[:new_file]
185
- ).to include("/lineup/tests/rspec/screenshots/sport_600_new.png")
232
+ ).to include("/lineup/tests/rspec/screenshots/?q=somethingelse_#{width}_new.png")
186
233
  # And
187
234
  expect(
188
235
  (lineup.compare('base', 'new').first)[:difference_file]
189
- ).to include("/lineup/tests/rspec/screenshots/sport_600_DIFFERENCE.png")
236
+ ).to include("/lineup/tests/rspec/screenshots/?q=somethingelse_#{width}_DIFFERENCE.png")
190
237
 
191
238
  # And When
192
239
  lineup.save_json(json_path)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lineup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Finn
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-23 00:00:00.000000000 Z
12
+ date: 2016-02-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -151,6 +151,8 @@ files:
151
151
  - README.md
152
152
  - bin/lineup
153
153
  - doc/example.png
154
+ - doc/lineup.png
155
+ - doc/lineup_mini.png
154
156
  - lib/controller/browser.rb
155
157
  - lib/controller/comparer.rb
156
158
  - lib/helper.rb