lineup 0.6.0 → 0.7.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: 4f3e24b0859c6f0c12ecf146e1564082f7f8a6a3
4
- data.tar.gz: 08743eb9f69f2bd4b820c02a3799bd22e358acb5
3
+ metadata.gz: 07ab8f60bcebca9b0488e5c73d3ccbade289a521
4
+ data.tar.gz: 3dc3452596572439cc9e7f1342c496c93c7f487b
5
5
  SHA512:
6
- metadata.gz: 259f123498f086d61fb790aec5b791d0a99b273f3eb7ee34aa3989b9a654c7cfe6b01f6bff25495f4227bff1c4104183fc92b468695474d1ecb51f15b540bf4b
7
- data.tar.gz: 93f0f59e0ea444937fd85d0d9338be16bbfdb712186a4f69a1c8b2248a5b0a8c157c47c923be86931490b31bcc1b67814188ff44c4467d669f8f2c0cf5f37154
6
+ metadata.gz: 8ffe89fd8929d9c4bb7ad910acbb1d3bb90bcd08ba8480f8a679b187de182bcd228434067c22521d877752e52e8aacc5fede9ce23e3f3379e92f52b1533bd416
7
+ data.tar.gz: 9fa37586804eff1aa5d75a097333f6df8464ca811eff5ba7c0cb340da6c58f590e5295f89b4e993f6368f7a7e81cd6ce17f20aa646698293c8cf7bfed5591d96
data/bin/lineup CHANGED
@@ -4,11 +4,7 @@ require '../lib/lineup'
4
4
 
5
5
  puts("This is an example. And a benchmark.")
6
6
 
7
- lineup = Lineup::Screenshot.new('https://prelive.otto.de')
8
- lineup.urls("/,multimedia,moebel,damenmode,mittesten")
9
- lineup.cookies([{"name"=>"trackingDisabled","value"=>"true","secure"=>false,"path"=>"/","domain"=>".otto.de"},
10
- {"name"=>"survey","value"=>"1","secure"=>false,"path"=>"/","domain"=>".otto.de"}])
11
- lineup.localStorage(["us_customerServiceWidget"=>"{'customerServiceWidgetNotificationHidden':{'value':true,'timestamp':1467723066080}}"])
7
+ lineup = Lineup::Screenshot.new('https://google.de')
12
8
  lineup.resolutions("600,800,1200")
13
9
  lineup.use_phantomjs false
14
10
  lineup.wait_for_asynchron_pages(2)
@@ -77,9 +77,9 @@ class Browser
77
77
  end
78
78
 
79
79
  if @localStorage.any?
80
- @localStorage.each do |keyValue|
80
+ @localStorage.each do |key, value|
81
81
  # Generate javascript for localStorage.setItem, escaping single quotes in key and value
82
- stmt = "localStorage.setItem('" + keyValue.keys.first.gsub("'", "\\\\'") + "','" + keyValue.values.first.gsub("'", "\\\\'") + "')";
82
+ stmt = "localStorage.setItem('" + key.gsub("'", "\\\\'") + "','" + value.gsub("'", "\\\\'") + "')";
83
83
  @browser.execute_script(stmt)
84
84
  end
85
85
  end
@@ -170,40 +170,11 @@ module Lineup
170
170
  @difference_path = path
171
171
  end
172
172
 
173
-
174
- def cookie_for_experiment(cookie)
175
-
176
- # a hash for a cookie can be set here. this is optional.
177
- #
178
- # e.g {name: 'experiment', value: 'experiment_value', domain: 'domain.com', path: '/', expires: <Time>, secure: false}
179
- #
180
- # if it is not nil it has to be an array:
181
- if cookie
182
- # generate :symbol => "value" hash map from "symbol" => "value"
183
- cookie = cookie.inject({}) { |element, (symbol, value)| element[symbol.to_sym] = value; element }
184
-
185
- #Validation
186
- (raise "Cookie must be a hash of format
187
- {name: 'experiment', value: 'experiment_value', domain: 'domain.com', path: '/', expires: <Time>, secure: false}
188
- " unless cookie.is_a? Hash)
189
-
190
- raise "cookie must have value for :name" unless (cookie[:name]).is_a? String
191
- raise "cookie must have value for :value" unless (cookie[:value]).is_a? String
192
- raise "cookie must have value for :domain" unless (cookie[:domain]).is_a? String
193
- raise "cookie must have value for :path" unless (cookie[:path]).is_a? String
194
- raise "cookie must have value for :secure" if (cookie[:secure]) == nil
195
- end
196
-
197
- # assign the variable
198
-
199
- @cookie_for_experiment = cookie
200
- end
201
-
202
173
  def cookies(cookies)
203
174
 
204
175
  # a hash for cookies can be set here. this is optional.
205
176
  #
206
- # e.g {name: 'experiment', value: 'experiment_value', domain: 'domain.com', path: '/', expires: <Time>, secure: false}
177
+ # e.g {name: 'name', value: 'value', domain: 'domain.com', path: '/', expires: <Time>, secure: false}
207
178
  #
208
179
  # if it is not nil it has to be an array:
209
180
 
@@ -215,7 +186,7 @@ module Lineup
215
186
 
216
187
  #Validation
217
188
  (raise "Cookie must be a hash of format
218
- {name: 'experiment', value: 'experiment_value', domain: 'domain.com', path: '/', expires: <Time>, secure: false}
189
+ {name: 'name', value: 'value', domain: 'domain.com', path: '/', expires: <Time>, secure: false}
219
190
  " unless cookie.is_a? Hash)
220
191
 
221
192
  raise "cookie must have value for :name" unless (cookie[:name]).is_a? String
@@ -238,23 +209,19 @@ module Lineup
238
209
  #
239
210
  # if it is not nil it has to be an array:
240
211
 
241
- @localStorage = []
212
+ @localStorage = {}
242
213
  if localStorage
243
- localStorage.each do |keyValue|
244
- # generate :symbol => "value" hash map from "symbol" => "value"
245
- #keyValue = keyValue.inject({}) { |element, (symbol, value)| element[symbol.to_sym] = value; element }
246
-
247
- #Validation
248
- (raise "LocalStorage Key Value pair must be a hash of format
214
+ #Validation
215
+ (raise "LocalStorage must be a hash of format
249
216
  {'key'=>'value'}
250
- " unless keyValue.is_a? Hash)
217
+ " unless localStorage.is_a? Hash)
251
218
 
252
- raise "LocalStorage Key Value pair must have exactly one key" unless (keyValue.keys.length) == 1
253
- raise "LocalStorage Key Value pair must have exactly one value" unless (keyValue.values.length) == 1
254
- raise "LocalStorage Key Value pair must have a string as key" unless (keyValue.keys.first).is_a? String
255
- raise "LocalStorage Key Value pair must have a string as value" unless (keyValue.values.first).is_a? String
219
+ localStorage.each do |key, value|
220
+ raise "LocalStorage must have a string as key" if (key).empty?
221
+ raise "LocalStorage key must be a string" unless (key).is_a? String
222
+ raise "LocalStorage value must be a string" unless (value).is_a? String
256
223
 
257
- @localStorage.push(keyValue)
224
+ @localStorage[key] = value
258
225
  end
259
226
  end
260
227
 
@@ -293,23 +260,13 @@ module Lineup
293
260
  use_phantomjs(configuration["use_phantomjs"])
294
261
  difference_path(configuration["difference_path"])
295
262
  wait_for_asynchron_pages(configuration["wait_for_asynchron_pages"])
296
- cookie_for_experiment(configuration["cookie_for_experiment"])
297
263
  cookies(configuration["cookies"])
298
264
  localStorage(configuration["localStorage"])
299
265
 
300
- if @cookies
301
- cookies_merged= @cookies.inject([]) { |a, element| a << element.dup }
302
- else
303
- cookies_merged = []
304
- end
305
- if @cookie_for_experiment
306
- cookies_merged.push(@cookie_for_experiment)
307
- end
308
-
309
266
  # the method calls set the variables for the parameters, we return an array with all of them.
310
267
  # for the example above it is:
311
268
  # [["/multimedia", "/sport"], [600, 800, 1200], "~/images/", true, "#/images/diff"]
312
- [@urls, @resolutions, @screenshots_path, @headless, @difference_path, @wait_for_asynchron_pages, cookies_merged, @localStorage]
269
+ [@urls, @resolutions, @screenshots_path, @headless, @difference_path, @wait_for_asynchron_pages, @cookies, @localStorage]
313
270
  end
314
271
 
315
272
 
@@ -325,16 +282,7 @@ module Lineup
325
282
  # and saves the screenshot in the file
326
283
  # @screenshot_path
327
284
 
328
- if @cookies
329
- cookies_merged= @cookies.inject([]) { |a, element| a << element.dup }
330
- else
331
- cookies_merged = []
332
- end
333
- if @cookie_for_experiment
334
- cookies_merged.push(@cookie_for_experiment)
335
- end
336
-
337
- browser = Browser.new(@baseurl, @urls, @resolutions, @screenshots_path, @headless, @wait_for_asynchron_pages, cookies_merged, @localStorage)
285
+ browser = Browser.new(@baseurl, @urls, @resolutions, @screenshots_path, @headless, @wait_for_asynchron_pages, @cookies, @localStorage)
338
286
  # the only argument missing is if this is the "base" or "new" screenshot, this can be
339
287
  # passed as an argument. The value does not need to be "base" or "new", but can be anything
340
288
  browser.record(version)
@@ -358,7 +306,7 @@ module Lineup
358
306
  @urls.each { |url|
359
307
  @resolutions.each { |resolution|
360
308
  #threads[i] = Thread.new {
361
- @comparer.push(Comparer.new(base, new, @difference_path, @baseurl, [url], [resolution], @screenshots_path))
309
+ @comparer.push(Comparer.new(base, new, @difference_path, @baseurl, [url], [resolution], @screenshots_path))
362
310
  #}
363
311
  #i+=1;
364
312
  }
@@ -1,7 +1,7 @@
1
1
  module Lineup
2
2
  class Version
3
3
  MAJOR = 0
4
- MINOR = 6
4
+ MINOR = 7
5
5
  PATCH = 0
6
6
 
7
7
  class << self
@@ -30,7 +30,7 @@ describe '#screeshot_recorder' do
30
30
  # Then
31
31
  expect(
32
32
  lineup.load_json_config(file)
33
- ).to eq([['page1'], [13], 'screenshots/path', true, 'screenshots/path/difference', 5, [], []])
33
+ ).to eq([['page1'], [13], 'screenshots/path', true, 'screenshots/path/difference', 5, [], {}])
34
34
 
35
35
  # cleanup:
36
36
  FileUtils.rm file if (File.exists? file)
@@ -46,13 +46,6 @@ describe '#screeshot_recorder' do
46
46
  "use_phantomjs":true,
47
47
  "difference_path":"screenshots/path/difference",
48
48
  "wait_for_asynchron_pages":5,
49
- "cookie_for_experiment":{
50
- "name":"cookie1",
51
- "value":"11111",
52
- "domain":".google.de",
53
- "path":"/",
54
- "secure":false
55
- },
56
49
  "cookies" : [{
57
50
  "name":"cookie2",
58
51
  "value":"22222",
@@ -67,7 +60,7 @@ describe '#screeshot_recorder' do
67
60
  "path":"/",
68
61
  "secure":false
69
62
  }],
70
- "localStorage":[{"myKey1":"myValue1"},{"myKey2":"myValue2"}]
63
+ "localStorage":{"myKey1":"myValue1","myKey2":"myValue2"}
71
64
  }'
72
65
  save_json(json, file)
73
66
 
@@ -79,9 +72,8 @@ describe '#screeshot_recorder' do
79
72
  lineup.load_json_config(file)
80
73
  ).to eq([['page1', 'page2'], [13,42], 'screenshots/path', true, 'screenshots/path/difference', 5,
81
74
  [{:name=>"cookie2", :value=>"22222", :domain=>".google.de", :path=>"/", :secure=>false},
82
- {:name=>"cookie3", :value=>"33333", :domain=>".google.de", :path=>"/", :secure=>false},
83
- {:name=>"cookie1", :value=>"11111", :domain=>".google.de", :path=>"/", :secure=>false}],
84
- [{"myKey1"=>"myValue1"}, {"myKey2"=>"myValue2"}]])
75
+ {:name=>"cookie3", :value=>"33333", :domain=>".google.de", :path=>"/", :secure=>false}],
76
+ {"myKey1"=>"myValue1", "myKey2"=>"myValue2"}])
85
77
 
86
78
  # cleanup:
87
79
  FileUtils.rm file if (File.exists? file)
@@ -195,12 +187,12 @@ describe '#screeshot_recorder' do
195
187
  lineup.resolutions('400')
196
188
  lineup.wait_for_asynchron_pages(5)
197
189
  lineup.use_phantomjs(true)
198
- cookie = {"name" => "CONSENT",
190
+ cookie = [{"name" => "CONSENT",
199
191
  "value" => "YES+DE.de+V7",
200
192
  "domain" => ".google.de",
201
193
  "path" => "/",
202
- "secure" => false}
203
- lineup.cookie_for_experiment(cookie)
194
+ "secure" => false}]
195
+ lineup.cookies(cookie)
204
196
 
205
197
  lineup.record_screenshot('base')
206
198
  lineup.record_screenshot('new')
@@ -225,13 +217,6 @@ describe '#screeshot_recorder' do
225
217
  "use_phantomjs":true,
226
218
  "difference_path":"screenshots/path/difference",
227
219
  "wait_for_asynchron_pages":5,
228
- "cookie_for_experiment":{
229
- "name":"CONSENT",
230
- "value":"YES+DE.de+V7",
231
- "domain":".google.de",
232
- "path":"/",
233
- "secure":false
234
- },
235
220
  "cookies" : [{
236
221
  "name":"cookie2",
237
222
  "value":"22222",
@@ -277,7 +262,7 @@ describe '#screeshot_recorder' do
277
262
  "use_phantomjs":true,
278
263
  "difference_path":"screenshots/path/difference",
279
264
  "wait_for_asynchron_pages":5,
280
- "localStorage":[{"{\'mySpecialKey\'}":"{\'customerServiceWidgetNotificationHidden\':{\'value\':true,\'timestamp\':1467723066092}}"}]
265
+ "localStorage": {"{\'mySpecialKey\'}":"{\'myvalue\':{\'value\':test,\'timestamp\':1467723066092}}"}
281
266
  }'
282
267
  save_json(json, file)
283
268
  lineup = Lineup::Screenshot.new(BASE_URL)
@@ -302,7 +287,7 @@ describe '#screeshot_recorder' do
302
287
  "use_phantomjs":true,
303
288
  "difference_path":"screenshots/path/difference",
304
289
  "wait_for_asynchron_pages":5,
305
- "localStorage":[{"us_customerServiceWidget":"{\'customerServiceWidgetNotificationHidden\':{\'value\':true,\'timestamp\':1467723066092}}"},{"myKey2":"myValue2"}]
290
+ "localStorage":{"\'myKey\'":"{\'myValue\'}","myKey2":"myValue2"}
306
291
  }'
307
292
  save_json(json, file)
308
293
  lineup = Lineup::Screenshot.new(BASE_URL)
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.6.0
4
+ version: 0.7.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: 2016-07-05 00:00:00.000000000 Z
12
+ date: 2016-07-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec