wraith 2.8.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,14 +30,8 @@ screen_widths:
30
30
  - 1024
31
31
  - 1280
32
32
 
33
- # the engine to run Wraith with.
34
- browser:
35
- #phantomjs: "casperjs" # variant of PhantomJS that allows screenshots by element selector
36
- phantomjs: "phantomjs" # PhantomJS, built on top of Webkit and JavascriptCore (like Safari)
37
- #slimerjs: "slimerjs" # SlimerJS, built on top of Gecko and SpiderMonkey (like Firefox)
38
-
39
- # the file in charge of taking the screenshot
40
- snap_file: "javascript/phantom--nojs.js"
33
+ # the engine to run Wraith with. Examples: 'phantomjs', 'casperjs', 'slimerjs'
34
+ browser: "phantomjs"
41
35
 
42
36
  # the directory that your base screenshots will be stored in
43
37
  history_dir: 'shots_base'
@@ -5,19 +5,19 @@ domains:
5
5
 
6
6
  # Notice the absence of a `paths` property. When no paths are provided, Wraith defaults to
7
7
  # spidering mode to check your entire website.
8
-
9
- ​# A list of URLs to skip when spidering.
10
- # Ruby regular expressions can be used, if prefixed with `!ruby/regexp` as defined in the YAML Cookbook​.
11
- ​# See http://www.yaml.org/YAML_for_ruby.html#regexps
12
- spider_skips:​
13
- - /foo/bar.html # Matches /foo/bar.html explicitly
14
- - !ruby/regexp /^\/baz\// # Matches any URLs that start with /baz
15
-
16
- # the filename of the spider file to use. Default: spider.txt
8
+
9
+ # A list of URLs to skip when spidering.
10
+ # Ruby regular expressions can be used, if prefixed with `!ruby/regexp` as defined in the YAML Cookbook​.
11
+ # See http://www.yaml.org/YAML_for_ruby.html#regexps
12
+ spider_skips:
13
+ - /foo/bar.html # Matches /foo/bar.html explicitly
14
+ - !ruby/regexp /^\/baz\// # Matches any URLs that start with /baz
15
+
16
+ # the filename of the spider file to use. Default: spider.txt
17
17
  spider_file: example_com_spider.txt
18
-
19
- ​# the number of days to keep the site spider file
20
- spider_days: 10
18
+
19
+ # the number of days to keep the site spider file
20
+ spider_days: 10
21
21
 
22
22
  # amount of fuzz ImageMagick will use when comparing images. A higher fuzz makes the comparison less strict.
23
23
  fuzz: '20%'
@@ -35,13 +35,7 @@ screen_widths:
35
35
  - 1280
36
36
 
37
37
  # the engine to run Wraith with.
38
- browser:
39
- #phantomjs: "casperjs" # variant of PhantomJS that allows screenshots by element selector
40
- phantomjs: "phantomjs" # PhantomJS, built on top of Webkit and JavascriptCore (like Safari)
41
- #slimerjs: "slimerjs" # SlimerJS, built on top of Gecko and SpiderMonkey (like Firefox)
42
-
43
- # the file in charge of taking the screenshot
44
- snap_file: "javascript/phantom.js"
38
+ browser: "phantomjs"
45
39
 
46
40
  # the directory that your latest screenshots will be stored in
47
41
  directory: 'shots_nojs'
@@ -1,5 +1,12 @@
1
- module.exports = function (browserEngine) {
2
- browserEngine.wait(2000, function() {
3
- browserEngine.click('.ns-panel__hotspot--2');
1
+ module.exports = function (casper) {
2
+
3
+ /* you may want to test some interaction on the page */
4
+ casper.wait(2000, function() {
5
+ casper.click('.ns-panel__hotspot--2');
4
6
  });
7
+
8
+ /* or you may want to see how your page looks without JavaScript */
9
+ // casper.options.pageSettings.javascriptEnabled = false;
10
+ // casper.thenOpen(casper.page.url);
11
+
5
12
  }
@@ -1,9 +1,36 @@
1
- module.exports = function (browserEngine) {
2
- browserEngine.evaluate(function(){
1
+ module.exports = function (phantom) {
2
+
3
+ /* you may want to test some interaction on the page */
4
+ phantom.evaluate(function(){
3
5
  var a = document.querySelector('.ns-panel__hotspot--2');
4
6
  var e = document.createEvent('MouseEvents');
5
7
  e.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
6
8
  a.dispatchEvent(e);
7
9
  waitforload = true;
8
10
  });
11
+
12
+ /* or you may want to see how your page looks without JavaScript */
13
+ // phantom.settings.javascriptEnabled = false;
14
+ // phantom.open(phantom.page.url);
15
+
16
+ // You can place custom headers here, example below.
17
+ // page.customHeaders = {
18
+
19
+ // 'X-Candy-OVERRIDE': 'https://api.live.bbc.co.uk/'
20
+
21
+ // };
22
+
23
+ // If you want to set a cookie, just add your details below in the following way.
24
+
25
+ // phantom.addCookie({
26
+ // 'name': 'ckns_policy',
27
+ // 'value': '111',
28
+ // 'domain': '.bbc.co.uk'
29
+ // });
30
+ // phantom.addCookie({
31
+ // 'name': 'locserv',
32
+ // 'value': '1#l1#i=6691484:n=Oxford+Circus:h=e@w1#i=8:p=London@d1#1=l:2=e:3=e:4=2@n1#r=40',
33
+ // 'domain': '.bbc.co.uk'
34
+ // });
35
+
9
36
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wraith
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Blooman
@@ -10,160 +10,160 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-11-13 00:00:00.000000000 Z
13
+ date: 2015-12-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pry
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ">="
19
+ - - '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ">="
26
+ - - '>='
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rspec
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - ">="
33
+ - - '>='
34
34
  - !ruby/object:Gem::Version
35
35
  version: '0'
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - ">="
40
+ - - '>='
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: rake
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ">="
47
+ - - '>='
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ">="
54
+ - - '>='
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: image_size
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ">="
61
+ - - '>='
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ">="
68
+ - - '>='
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: anemone
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ">="
75
+ - - '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ">="
82
+ - - '>='
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: robotex
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - ">="
89
+ - - '>='
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - ">="
96
+ - - '>='
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: nokogiri
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ">="
103
+ - - '>='
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  type: :runtime
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - ">="
110
+ - - '>='
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: log4r
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ">="
117
+ - - '>='
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  type: :runtime
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ">="
124
+ - - '>='
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: thor
129
129
  requirement: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - ">="
131
+ - - '>='
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  type: :runtime
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - ">="
138
+ - - '>='
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: parallel
143
143
  requirement: !ruby/object:Gem::Requirement
144
144
  requirements:
145
- - - ">="
145
+ - - '>='
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  type: :runtime
149
149
  prerelease: false
150
150
  version_requirements: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - ">="
152
+ - - '>='
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  - !ruby/object:Gem::Dependency
156
156
  name: casperjs
157
157
  requirement: !ruby/object:Gem::Requirement
158
158
  requirements:
159
- - - ">="
159
+ - - '>='
160
160
  - !ruby/object:Gem::Version
161
161
  version: '0'
162
162
  type: :runtime
163
163
  prerelease: false
164
164
  version_requirements: !ruby/object:Gem::Requirement
165
165
  requirements:
166
- - - ">="
166
+ - - '>='
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  description: Wraith is a screenshot comparison tool, created by developers at BBC
@@ -177,11 +177,11 @@ executables:
177
177
  extensions: []
178
178
  extra_rdoc_files: []
179
179
  files:
180
- - ".gemset"
181
- - ".gitignore"
182
- - ".rubocop.yml"
183
- - ".ruby-version"
184
- - ".travis.yml"
180
+ - .gemset
181
+ - .gitignore
182
+ - .rubocop.yml
183
+ - .ruby-version
184
+ - .travis.yml
185
185
  - Dockerfile
186
186
  - Gemfile
187
187
  - LICENSE
@@ -198,34 +198,38 @@ files:
198
198
  - lib/wraith/gallery.rb
199
199
  - lib/wraith/gallery_template/basic_template.erb
200
200
  - lib/wraith/gallery_template/slideshow_template.erb
201
+ - lib/wraith/javascript/_helper.js
202
+ - lib/wraith/javascript/_phantom__common.js
203
+ - lib/wraith/javascript/casper.js
204
+ - lib/wraith/javascript/phantom--nojs.js
205
+ - lib/wraith/javascript/phantom.js
201
206
  - lib/wraith/save_images.rb
202
207
  - lib/wraith/spider.rb
203
208
  - lib/wraith/thumbnails.rb
204
209
  - lib/wraith/version.rb
205
210
  - lib/wraith/wraith.rb
211
+ - spec/_helpers.rb
206
212
  - spec/base/global.png
207
213
  - spec/base/path.png
214
+ - spec/before_capture_spec.rb
215
+ - spec/config_spec.rb
208
216
  - spec/configs/test_config--casper.yaml
209
217
  - spec/configs/test_config--phantom.yaml
210
- - spec/helpers.rb
218
+ - spec/gallery_spec.rb
219
+ - spec/js/custom_snap_file.js
211
220
  - spec/js/global.js
212
221
  - spec/js/path.js
222
+ - spec/resize_reload_spec.rb
223
+ - spec/save_images_spec.rb
213
224
  - spec/thumbnails/home/test_image-afrique.png
214
225
  - spec/thumbnails/home/test_image-diff.png
215
226
  - spec/thumbnails/home/test_image-russian.png
216
- - spec/wraith_spec.rb
217
227
  - templates/README.md
218
228
  - templates/configs/component.yaml
219
229
  - templates/configs/multiple_domains.yaml
220
230
  - templates/configs/spider.yaml
221
- - templates/javascript/README.md
222
- - templates/javascript/_getDimensions.js
223
- - templates/javascript/_phantom__common.js
224
231
  - templates/javascript/beforeCapture--casper_example.js
225
232
  - templates/javascript/beforeCapture--phantom_example.js
226
- - templates/javascript/casper.js
227
- - templates/javascript/phantom--nojs.js
228
- - templates/javascript/phantom.js
229
233
  - wraith.gemspec
230
234
  homepage: https://github.com/BBC-News/wraith
231
235
  licenses:
@@ -237,29 +241,34 @@ require_paths:
237
241
  - lib
238
242
  required_ruby_version: !ruby/object:Gem::Requirement
239
243
  requirements:
240
- - - ">="
244
+ - - '>='
241
245
  - !ruby/object:Gem::Version
242
246
  version: '0'
243
247
  required_rubygems_version: !ruby/object:Gem::Requirement
244
248
  requirements:
245
- - - ">="
249
+ - - '>='
246
250
  - !ruby/object:Gem::Version
247
251
  version: '0'
248
252
  requirements: []
249
253
  rubyforge_project:
250
- rubygems_version: 2.4.5.1
254
+ rubygems_version: 2.4.8
251
255
  signing_key:
252
256
  specification_version: 4
253
257
  summary: Wraith is a screenshot comparison tool, created by developers at BBC News.
254
258
  test_files:
259
+ - spec/_helpers.rb
255
260
  - spec/base/global.png
256
261
  - spec/base/path.png
262
+ - spec/before_capture_spec.rb
263
+ - spec/config_spec.rb
257
264
  - spec/configs/test_config--casper.yaml
258
265
  - spec/configs/test_config--phantom.yaml
259
- - spec/helpers.rb
266
+ - spec/gallery_spec.rb
267
+ - spec/js/custom_snap_file.js
260
268
  - spec/js/global.js
261
269
  - spec/js/path.js
270
+ - spec/resize_reload_spec.rb
271
+ - spec/save_images_spec.rb
262
272
  - spec/thumbnails/home/test_image-afrique.png
263
273
  - spec/thumbnails/home/test_image-diff.png
264
274
  - spec/thumbnails/home/test_image-russian.png
265
- - spec/wraith_spec.rb
data/spec/wraith_spec.rb DELETED
@@ -1,209 +0,0 @@
1
- require "rspec"
2
- require "image_size"
3
- require "helpers"
4
- require "./lib/wraith/cli"
5
-
6
- describe Wraith do
7
- let(:config_name) { get_path_relative_to __FILE__, "./configs/test_config--phantom.yaml" }
8
- let(:test_url1) { "http://www.bbc.com/afrique" }
9
- let(:test_url2) { "http://www.bbc.com/russian" }
10
- let(:test_image1) { "shots/test/test1.png" }
11
- let(:test_image2) { "shots/test/test(2).png" }
12
- let(:diff_image) { "shots/test/test_diff.png" }
13
- let(:data_txt) { "shots/test/test.txt" }
14
- let(:selector) { "" }
15
- let(:saving) { Wraith::SaveImages.new(config_name) }
16
- let(:wraith) { Wraith::Wraith.new(config_name) }
17
-
18
- before(:each) do
19
- Wraith::FolderManager.new(config_name).clear_shots_folder
20
- Dir.mkdir("shots/test")
21
- end
22
-
23
- describe "Config" do
24
- it "returns a Wraith class" do
25
- expect(wraith).is_a? Wraith::Wraith
26
- end
27
-
28
- it "when config is loaded" do
29
- expect(wraith).to respond_to :config
30
- end
31
-
32
- it "contains shot options" do
33
- expect(wraith.config).to include "directory" => "shots"
34
- end
35
- end
36
-
37
- context "When creating a wraith worker" do
38
- it "should have 7 config keys" do
39
- expect(wraith.config.keys.size).to be 7
40
- end
41
-
42
- it "should have widths" do
43
- expect(wraith.widths).to eq [320, 600, 1280]
44
- end
45
-
46
- it "include base domain" do
47
- expect(wraith.base_domain).to eq "http://www.bbc.com/afrique"
48
- end
49
-
50
- it "include compare domain" do
51
- expect(wraith.comp_domain).to eq "http://www.bbc.com/russian"
52
- end
53
-
54
- it "include base label" do
55
- expect(wraith.base_domain_label).to eq "afrique"
56
- end
57
-
58
- it "include compare label" do
59
- expect(wraith.comp_domain_label).to eq "russian"
60
- end
61
-
62
- it "include compare label" do
63
- expect(wraith.paths).to eq("home" => "/", "uk_index" => "/uk")
64
- end
65
- end
66
-
67
- describe "When capturing an image" do
68
- let(:image_size) { ImageSize.path(test_image1).size }
69
-
70
- it "saves image" do
71
- wraith.engine.each do |_type, engine|
72
- saving.capture_page_image(engine, test_url1, 320, test_image1, selector, 'false', 'false')
73
- end
74
-
75
- expect(image_size[0]).to eq 320
76
- end
77
- end
78
-
79
- describe "When comparing images" do
80
- it "should compare" do
81
- create_diff_image
82
- crop_images
83
- compare_images
84
-
85
- diff = ImageSize.path(diff_image).size
86
-
87
- expect(diff[0]).to eq 320
88
- end
89
- end
90
-
91
- describe "When generating thumbnails" do
92
- it "produce thumbnails" do
93
- create_diff_image
94
- crop_images
95
- Wraith::CompareImages.new(config_name).compare_task(test_image1, test_image2, diff_image, data_txt)
96
- Wraith::Thumbnails.new(config_name).generate_thumbnails
97
-
98
- expect(File).to exist("shots/thumbnails/test/test1.png")
99
- expect(File).to exist("shots/thumbnails/test/test(2).png")
100
- expect(File).to exist("shots/thumbnails/test/test_diff.png")
101
- end
102
- end
103
-
104
- describe "When generating gallery" do
105
- let(:gallery) { Wraith::GalleryGenerator.new(config_name, false) }
106
-
107
- it "should not break when there is a `-` in the filename" do
108
- dirs = gallery.parse_directories 'spec/thumbnails'
109
-
110
- images = [
111
- {
112
- :filename => 'home/test_image-afrique.png',
113
- :thumb => 'thumbnails/home/test_image-afrique.png'
114
- },
115
- {
116
- :filename => 'home/test_image-russian.png',
117
- :thumb => 'thumbnails/home/test_image-russian.png'
118
- }
119
- ]
120
-
121
- dirs['home'][0][:variants].each_with_index do |image, i|
122
- expect(image[:filename]).to eq images[i][:filename]
123
- expect(image[:thumb]).to eq images[i][:thumb]
124
- end
125
-
126
- diff = {
127
- :filename => 'home/test_image-diff.png',
128
- :thumb => 'thumbnails/home/test_image-diff.png'
129
- }
130
-
131
- expect(dirs['home'][0][:diff][:filename]).to eq 'home/test_image-diff.png'
132
- expect(dirs['home'][0][:diff][:thumb]).to eq 'thumbnails/home/test_image-diff.png'
133
- end
134
- end
135
-
136
- describe "When hooking into beforeCapture (CasperJS)" do
137
- let(:config_name) { get_path_relative_to __FILE__, "./configs/test_config--casper.yaml" }
138
- let(:saving) { Wraith::SaveImages.new(config_name) }
139
- let(:wraith) { Wraith::Wraith.new(config_name) }
140
- let(:selector) { "body" }
141
- let(:before_suite_js) { "spec/js/global.js" }
142
- let(:before_capture_js) { "spec/js/path.js" }
143
-
144
- it "Executes the global JS before capturing" do
145
- run_js_then_capture(
146
- global_js: before_suite_js,
147
- path_js: 'false',
148
- output_should_look_like: 'spec/base/global.png',
149
- engine: 'casperjs'
150
- )
151
- end
152
-
153
- it "Executes the path-level JS before capturing" do
154
- run_js_then_capture(
155
- global_js: 'false',
156
- path_js: before_capture_js,
157
- output_should_look_like: 'spec/base/path.png',
158
- engine: 'casperjs'
159
- )
160
- end
161
-
162
- it "Executes the global JS before the path-level JS" do
163
- run_js_then_capture(
164
- global_js: before_suite_js,
165
- path_js: before_capture_js,
166
- output_should_look_like: 'spec/base/path.png',
167
- engine: 'casperjs'
168
- )
169
- end
170
- end
171
-
172
- # @TODO - uncomment and figure out why broken
173
- # describe "When hooking into beforeCapture (PhantomJS)" do
174
- # let(:config_name) { get_path_relative_to __FILE__, "./configs/test_config--phantom.yaml" }
175
- # let(:saving) { Wraith::SaveImages.new(config_name) }
176
- # let(:wraith) { Wraith::Wraith.new(config_name) }
177
- # let(:selector) { "body" }
178
- # let(:before_suite_js) { "../../spec/js/global.js" }
179
- # let(:before_capture_js) { "../../spec/js/path.js" }
180
-
181
- # it "Executes the global JS before capturing" do
182
- # run_js_then_capture(
183
- # global_js: before_suite_js,
184
- # path_js: 'false',
185
- # output_should_look_like: 'spec/base/global.png',
186
- # engine: 'phantomjs'
187
- # )
188
- # end
189
-
190
- # it "Executes the path-level JS before capturing" do
191
- # run_js_then_capture(
192
- # global_js: 'false',
193
- # path_js: before_capture_js,
194
- # output_should_look_like: 'spec/base/path.png',
195
- # engine: 'phantomjs'
196
- # )
197
- # end
198
-
199
- # it "Executes the global JS before the path-level JS" do
200
- # run_js_then_capture(
201
- # global_js: before_suite_js,
202
- # path_js: before_capture_js,
203
- # output_should_look_like: 'spec/base/path.png',
204
- # engine: 'phantomjs'
205
- # )
206
- # end
207
- # end
208
-
209
- end