lineup 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca168f6253bc6111e22696d8b4f72e5a468ca804
4
- data.tar.gz: bc2ffad3a74d03b3dbff81e5f980d81fd1c76644
3
+ metadata.gz: 750f82676b714c5dfa3a2ed55e48e941f16dcd3b
4
+ data.tar.gz: d22624093175f3ce9fff65c76a7505310b4b23f6
5
5
  SHA512:
6
- metadata.gz: a87243428920002cd40dc99f824d97dc98630dccd022cc579e3dea71718598b7242fab291abf0b85dac13a86596b9dd0b394c1644ce48d32bda1b73badcd4592
7
- data.tar.gz: 10ea27a5f54e0cb04ed9da5881ba276978d599c29be3c38dfb7fb983fd11349365746ac7cf93e70aaa630a48979da66688f95c355a2e4359b82cc6cf4e92935f
6
+ metadata.gz: c18638ee77d83b11c2b9358eb8d6c35ae54822a2f4fceb0d5b1c52e2e0e7c49a250a354b9202611fd6a78fb63a8e17277b48465aadd213d3e2079a073f69167d
7
+ data.tar.gz: e5ea889f6f5163f462fb3231e4408865df4ae20b55f0f2f44b90e1d50e36c4aa0c9558849855b143fb11aa39290c5131ac5122c8dbb24e1e256195e42979f862
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Lineup
2
2
 
3
3
  Lineup is doing automated testing of webpage designs, eg. in continious delivery.
4
- If you push new code to production, you can evaluate the design of you page compared to a defined base design and
4
+ If you push new code to production, you can evaluate the design of your page compared to a defined base design and
5
5
  get an analysis about the difference of the designs:
6
6
 
7
7
  For all images that you want to compare, you will receive information about how many pixel are different
@@ -51,7 +51,7 @@ lineup.compare('new', 'base')
51
51
  You can save it for later use:
52
52
  ````ruby
53
53
  lineup.save_json('/home/name/lineup/results/')
54
- => '/home/name/lineup/results/json.log'
54
+ => '/home/name/lineup/results/log.json'
55
55
  ````
56
56
 
57
57
  ## More configuration:
@@ -61,7 +61,7 @@ There are multiple ways to specify what to lineup and compare.
61
61
  By specifying different urls via ````#urls````:
62
62
  ````ruby
63
63
  lineup = Lineup::Screenshot.new('https://www.otto.de')
64
- lineup.urls("/, /multimedia, /sport")
64
+ lineup.urls('/, /multimedia, /sport')
65
65
  ````
66
66
  This will do analysis of otto.de root (frontpage), otto.de/multimedia and otto.de/sport.
67
67
  It requires a comma separated string. Default value is only root.
@@ -69,22 +69,30 @@ It requires a comma separated string. Default value is only root.
69
69
  By specifying different resolutions via ````#resolutions````:
70
70
  ````ruby
71
71
  lineup = Lineup::Screenshot.new('https://www.otto.de')
72
- lineup.resolutions("600, 800, 1200")
72
+ lineup.resolutions('600, 800, 1200')
73
73
  ````
74
74
  The values are the browser width in pixel. For each size an analysis is done.
75
75
  It require a comma separated string. Default values are 640px, 800px and 1180px.
76
76
 
77
+ By specifying a wait time for asychron elements on a page via ````#wait_for_asynchron_pages````:
78
+ ````ruby
79
+ lineup = Lineup::Screenshot.new('https://www.otto.de')
80
+ lineup.wait_for_asynchron_pages(5)
81
+ ````
82
+ The wait time is the time in seconds lineup will wait after the page load before it takes a screenshot.
83
+ In this time third party tools, AJAX or js as well as fonts can be (lazy) loaded. The wait time has no upper limit.
84
+
77
85
  By specifying a filepath for the screenshots via ````#filepath_for_images````:
78
86
  ````ruby
79
87
  lineup = Lineup::Screenshot.new('https://www.otto.de')
80
- lineup.filepath_for_images(/home/myname/lineup/screenshots)
88
+ lineup.filepath_for_images('/home/myname/lineup/screenshots')
81
89
  ````
82
90
  Creates a file and saves the screenshots in the file. Default is ````"#{Dir.pwd}/screenshots"````
83
91
 
84
92
  By specifying a filepath for the difference image via ````#difference_path````:
85
93
  ````ruby
86
94
  lineup = Lineup::Screenshot.new('https://www.otto.de')
87
- lineup.difference_path(/home/myname/lineup/result)
95
+ lineup.difference_path('/home/myname/lineup/result')
88
96
  ````
89
97
  Creates a file and saves the difference image in the file. Default is ````"#{Dir.pwd}/screenshots"````
90
98
 
@@ -98,7 +106,7 @@ If ````false```` the screenshots are taken in Firefox. ````#load_json_config````
98
106
  Load all above configs from a json file via
99
107
  ````ruby
100
108
  lineup = Lineup::Screenshot.new('https://www.otto.de')
101
- lineup.load_json_config(/home/myname/lineup/config.json)
109
+ lineup.load_json_config('/home/myname/lineup/config.json')
102
110
  ````
103
111
  While my file contains all relevant information
104
112
  ````json
@@ -106,10 +114,13 @@ While my file contains all relevant information
106
114
  "urls":"/multimedia, /sport",
107
115
  "resolutions":"600,800,1200",
108
116
  "filepath_for_images":"~/images/",
109
- "use_headless":true,
110
- "difference_path":"#/images/diff"
117
+ "use_phantomjs":true,
118
+ "difference_path":"#/images/diff",
119
+ "wait_for_asynchron_pages":5
111
120
  }
112
121
  ````
122
+ However, if the configuration is done with a json object, it needs to contain all information, there
123
+ is no optional parameter.
113
124
 
114
125
  ## Example:
115
126
 
@@ -121,13 +132,14 @@ resolutions = '600, 800, 1200'
121
132
  images_path = '/home/myname/lineup/screenshots'
122
133
  difference_path = '/home/myname/lineup/results'
123
134
  json_path = 'home/myname/lineup/results'
124
- phantom = true
135
+ phantomjs = true
125
136
 
126
137
  lineup = Lineup::Screenshot.new('https://www.otto.de')
127
138
  lineup.urls(urls)
128
139
  lineup.resolutions(resolutions)
129
140
  lineup.filepath_for_images(images_path
130
141
  lineup.difference_path(difference_path)
142
+ lineup.use_phantomjs(phantomjs)
131
143
 
132
144
  lineup.record_screenshot(base_name)
133
145
  # do sth. (eg. deploy new software)
@@ -7,13 +7,14 @@ require_relative '../helper'
7
7
 
8
8
  class Browser
9
9
 
10
- def initialize(baseurl, urls, resolutions, path, headless)
10
+ def initialize(baseurl, urls, resolutions, path, headless, wait)
11
11
  @absolute_image_path = path
12
12
  FileUtils.mkdir_p @absolute_image_path
13
13
  @baseurl = baseurl
14
14
  @urls = urls
15
15
  @resolutions = resolutions
16
16
  @headless = headless
17
+ @wait = wait
17
18
  end
18
19
 
19
20
  def record(version)
@@ -52,6 +53,7 @@ class Browser
52
53
  @browser.cookies.clear
53
54
  url = Helper.url(@baseurl, url)
54
55
  @browser.goto url
56
+ sleep @wait if @wait
55
57
  @browser.screenshot.save( File.expand_path(filename))
56
58
  end
57
59
 
@@ -1,7 +1,7 @@
1
1
  module Lineup
2
2
  class Version
3
3
  MAJOR = 0
4
- MINOR = 1
4
+ MINOR = 2
5
5
  PATCH = 0
6
6
 
7
7
  class << self
data/lib/lineup.rb CHANGED
@@ -174,6 +174,24 @@ module Lineup
174
174
 
175
175
 
176
176
 
177
+ def wait_for_asynchron_pages(wait)
178
+
179
+ # if required a wait time in seconds can be set. This may be needed, if after pageload some
180
+ # elements are still loaded (Third-Party-Tools, AJAX, JS, Fonts)
181
+ #
182
+ # this value is a number (integer) how many seconds lineup will wait before taking a screenshot
183
+ #
184
+ # if its not an integer an exception is raised
185
+
186
+ raise "wait time needs to be an integer (wait time in seconds)" unless wait.is_a? Integer
187
+
188
+ # assign the variable
189
+
190
+ @wait_for_asynchron_pages = wait
191
+ end
192
+
193
+
194
+
177
195
  def load_json_config(path)
178
196
 
179
197
  # loads all possible configs from a json file.
@@ -190,11 +208,12 @@ module Lineup
190
208
  filepath_for_images(configuration["filepath_for_images"])
191
209
  use_phantomjs(configuration["use_phantomjs"])
192
210
  difference_path(configuration["difference_path"])
211
+ wait_for_asynchron_pages(configuration["wait_for_asynchron_pages"])
193
212
 
194
213
  # the method calls set the variables for the parameters, we return an array with all of them.
195
214
  # for the example above it is:
196
215
  # [["/multimedia", "/sport"], [600, 800, 1200], "~/images/", true, "#/images/diff"]
197
- [@urls, @resolutions, @screenshots_path, @headless, @difference_path]
216
+ [@urls, @resolutions, @screenshots_path, @headless, @difference_path, @wait_for_asynchron_pages]
198
217
  end
199
218
 
200
219
 
@@ -211,7 +230,7 @@ module Lineup
211
230
  # and saves the screenshot in the file
212
231
  # @screenshot_path
213
232
 
214
- browser = Browser.new(@baseurl, @urls, @resolutions, @screenshots_path, @headless)
233
+ browser = Browser.new(@baseurl, @urls, @resolutions, @screenshots_path, @headless, @wait_for_asynchron_pages)
215
234
 
216
235
  # the only argument missing is if this is the "base" or "new" screenshot, this can be
217
236
  # passed as an argument. The value does not need to be "base" or "new", but can be anything
@@ -15,7 +15,7 @@ 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"}'
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}'
19
19
  save_json(json, file)
20
20
 
21
21
  # When
@@ -24,7 +24,7 @@ describe '#screeshot_recorder' do
24
24
  # Then
25
25
  expect(
26
26
  lineup.load_json_config(file)
27
- ).to eq([['page1', 'page2'], [13,42], 'some/path', true, 'some/difference/image/path'])
27
+ ).to eq([['page1', 'page2'], [13,42], 'some/path', true, 'some/difference/image/path', 5])
28
28
 
29
29
  # cleanup:
30
30
  FileUtils.rm file if (File.exists? file)
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.1.0
4
+ version: 0.2.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-09-24 00:00:00.000000000 Z
12
+ date: 2015-10-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: lineup takes to screenshots of your app and compares them to references
15
15
  in order to find design flaws in your new code.
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  version: '0'
53
53
  requirements: []
54
54
  rubyforge_project:
55
- rubygems_version: 2.4.8
55
+ rubygems_version: 2.4.5.1
56
56
  signing_key:
57
57
  specification_version: 4
58
58
  summary: lineup will help you in your automated design regression testing