capybara-screenshot-diff 0.6.0 → 0.7.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c51c0b3910c0d9084516caa214cc4def9f3555e5
|
4
|
+
data.tar.gz: d6a6c7b9c780bba92792dea8d18ad5e6a4309004
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff97131d3381c1db29293d78c70d090ef0f08e31878f2c680305bf2e0205d79257acfee39769b0025d75a56137ed6ef31338333ac682571c2856118cffb3560c
|
7
|
+
data.tar.gz: 55375885f91dff602b8744a46254261597fc19d1066057e350623bcb96152f0c28853be88b4436920c91e54e9d8f084c913454e4c23148bd0f3bb986e5331c61
|
data/.rubocop_todo.yml
CHANGED
@@ -16,12 +16,12 @@ Layout/IndentHeredoc:
|
|
16
16
|
|
17
17
|
# Offense count: 7
|
18
18
|
Metrics/AbcSize:
|
19
|
-
Max:
|
19
|
+
Max: 28
|
20
20
|
|
21
21
|
# Offense count: 1
|
22
22
|
# Configuration parameters: CountComments.
|
23
23
|
Metrics/ClassLength:
|
24
|
-
Max:
|
24
|
+
Max: 188
|
25
25
|
|
26
26
|
# Offense count: 2
|
27
27
|
Metrics/CyclomaticComplexity:
|
data/README.md
CHANGED
@@ -243,10 +243,24 @@ Capybara::Screenshot.stability_time_limit = 0.5
|
|
243
243
|
|
244
244
|
|
245
245
|
|
246
|
+
### Removing focus from the active element
|
247
|
+
|
248
|
+
In Chrome the screenshot includes the blinking input cursor. This can make it impossible to get a
|
249
|
+
stable screenshot. To get around this you can set the `blur_active_element` option:
|
250
|
+
|
251
|
+
```ruby
|
252
|
+
Capybara::Screenshot.blur_active_element = true
|
253
|
+
```
|
254
|
+
|
255
|
+
This will remove the focus from the active element, removing the blinking cursor.
|
256
|
+
|
257
|
+
|
258
|
+
|
246
259
|
### Allowed color distance
|
247
260
|
|
248
|
-
Sometimes you want to allow small differences in the images.
|
249
|
-
|
261
|
+
Sometimes you want to allow small differences in the images. For example, Chrome renders the same
|
262
|
+
page slightly differently sometimes. You can set set the difference threshold for the comparison
|
263
|
+
using the `color_distance_limit` option to the `screenshot` method:
|
250
264
|
|
251
265
|
```ruby
|
252
266
|
test 'color threshold' do
|
@@ -196,6 +196,7 @@ EOF
|
|
196
196
|
|
197
197
|
private def take_stable_screenshot(comparison)
|
198
198
|
assert_images_loaded
|
199
|
+
execute_script('document.activeElement.blur()') if Capybara::Screenshot.blur_active_element
|
199
200
|
previous_file_size = comparison.old_file_size
|
200
201
|
screeenshot_started_at = last_image_change_at = Time.now
|
201
202
|
loop do
|
@@ -236,7 +237,7 @@ EOF
|
|
236
237
|
|
237
238
|
def assert_image_not_changed(caller, name, comparison)
|
238
239
|
return unless comparison.different?
|
239
|
-
"Screenshot does not match for '#{name}' (area: #{comparison.size} #{comparison.dimensions}" \
|
240
|
+
"Screenshot does not match for '#{name}' (area: #{comparison.size}px #{comparison.dimensions}" \
|
240
241
|
", max_color_distance: #{comparison.max_color_distance.round(1)})\n" \
|
241
242
|
"#{comparison.new_file_name}\n#{comparison.annotated_old_file_name}\n" \
|
242
243
|
"#{comparison.annotated_new_file_name}\n" \
|
@@ -29,7 +29,7 @@ module Capybara
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def reset
|
32
|
-
@max_color_distance = 0
|
32
|
+
@max_color_distance = @color_distance_limit ? 0 : nil
|
33
33
|
@left = @top = @right = @bottom = nil
|
34
34
|
end
|
35
35
|
|
@@ -229,13 +229,12 @@ module Capybara
|
|
229
229
|
private def same_color?(old_img, new_img, x, y)
|
230
230
|
org_color = old_img[x, y]
|
231
231
|
new_color = new_img[x, y]
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
end
|
232
|
+
return true if org_color == new_color
|
233
|
+
|
234
|
+
distance = ChunkyPNG::Color.euclidean_distance_rgba(org_color, new_color)
|
235
|
+
@max_color_distance = distance if !@max_color_distance || distance > @max_color_distance
|
236
|
+
|
237
|
+
@color_distance_limit && @color_distance_limit > 0 && distance <= @color_distance_limit
|
239
238
|
end
|
240
239
|
end
|
241
240
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-screenshot-diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uwe Kubosch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|