capybara-screenshot-diff 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +1 -1
- data/README.md +6 -0
- data/lib/capybara/screenshot/diff.rb +1 -0
- data/lib/capybara/screenshot/diff/image_compare.rb +2 -3
- data/lib/capybara/screenshot/diff/stabilization.rb +5 -5
- data/lib/capybara/screenshot/diff/test_methods.rb +3 -1
- data/lib/capybara/screenshot/diff/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4b74b3421312a6837944115244ae03eb5b59b65b28dd21fed17ad9f13672b32
|
4
|
+
data.tar.gz: 9d60292db9261447214601ff3e498adb81cb5ce51899db8c19f18ac66ea53d6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c529cfbf50e5b11251d4c44115713a99aac84c712dc62770d6cdc735adeba814ffc62e68acaa2fdf8e77fc6171b37269b37fbb2d669915a80a44c4d9ef7a523a
|
7
|
+
data.tar.gz: 9b6f02f0c296a53fca5acba02b36b838bc83ac8616606029f44122a08537b930e122ce1398ec152f2dfc02e65b207042ba24c37f899cb7d6586c2588c6cd60f6
|
data/.rubocop_todo.yml
CHANGED
data/README.md
CHANGED
@@ -409,6 +409,12 @@ The arguments are [x1, y1, x2, y2] for the area you want to ignore. You can als
|
|
409
409
|
Capybara::Screenshot::Diff.skip_area = [0, 0, 64, 48]
|
410
410
|
```
|
411
411
|
|
412
|
+
If you need to ignore multiple areas, you can supply an array of arrays:
|
413
|
+
|
414
|
+
```ruby
|
415
|
+
screenshot 'index', skip_area: [[0, 0, 64, 48], [17, 6, 27, 16]]
|
416
|
+
```
|
417
|
+
|
412
418
|
|
413
419
|
## Development
|
414
420
|
|
@@ -277,9 +277,8 @@ module Capybara
|
|
277
277
|
end
|
278
278
|
|
279
279
|
def same_color?(old_img, new_img, x, y)
|
280
|
-
|
281
|
-
|
282
|
-
return true
|
280
|
+
@skip_area&.each do |skip_start_x, skip_start_y, skip_end_x, skip_end_y|
|
281
|
+
return true if skip_start_x <= x && x <= skip_end_x && skip_start_y <= y && y <= skip_end_y
|
283
282
|
end
|
284
283
|
|
285
284
|
color_distance =
|
@@ -25,7 +25,7 @@ module Capybara
|
|
25
25
|
blurred_input = prepare_page_for_screenshot
|
26
26
|
previous_file_name = comparison.old_file_name
|
27
27
|
screenshot_started_at = last_image_change_at = Time.now
|
28
|
-
|
28
|
+
1.step do |i|
|
29
29
|
take_right_size_screenshot(comparison)
|
30
30
|
|
31
31
|
break unless Capybara::Screenshot.stability_time_limit
|
@@ -118,9 +118,9 @@ module Capybara
|
|
118
118
|
def check_max_wait_time(comparison, screenshot_started_at, shift_distance_limit:)
|
119
119
|
shift_factor = shift_distance_limit ? (shift_distance_limit * 2 + 1) ^ 2 : 1
|
120
120
|
max_wait_time = Capybara.default_max_wait_time * shift_factor
|
121
|
-
assert
|
121
|
+
assert((Time.now - screenshot_started_at) < max_wait_time,
|
122
122
|
"Could not get stable screenshot within #{max_wait_time}s\n" \
|
123
|
-
"#{stabilization_images(comparison.new_file_name).join("\n")}"
|
123
|
+
"#{stabilization_images(comparison.new_file_name).join("\n")}")
|
124
124
|
end
|
125
125
|
|
126
126
|
def assert_images_loaded(timeout: Capybara.default_max_wait_time)
|
@@ -131,8 +131,8 @@ module Capybara
|
|
131
131
|
pending_image = evaluate_script IMAGE_WAIT_SCRIPT
|
132
132
|
break unless pending_image
|
133
133
|
|
134
|
-
assert
|
135
|
-
"Images not loaded after #{timeout}s: #{pending_image.inspect}"
|
134
|
+
assert((Time.now - start) < timeout,
|
135
|
+
"Images not loaded after #{timeout}s: #{pending_image.inspect}")
|
136
136
|
sleep 0.1
|
137
137
|
end
|
138
138
|
end
|
@@ -70,10 +70,12 @@ module Capybara
|
|
70
70
|
# @return [Boolean] wether a screenshot was taken
|
71
71
|
def screenshot(name, color_distance_limit: Diff.color_distance_limit,
|
72
72
|
shift_distance_limit: Diff.shift_distance_limit, area_size_limit: Diff.area_size_limit,
|
73
|
-
skip_area:
|
73
|
+
skip_area: Diff.skip_area)
|
74
74
|
return unless Screenshot.active?
|
75
75
|
return if window_size_is_wrong?
|
76
76
|
|
77
|
+
skip_area = skip_area&.flatten&.each_cons(4)&.to_a # Allow nil or single or multiple areas
|
78
|
+
|
77
79
|
if @screenshot_counter
|
78
80
|
name = "#{format('%02i', @screenshot_counter)}_#{name}"
|
79
81
|
@screenshot_counter += 1
|
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: 1.0
|
4
|
+
version: 1.1.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: 2019-
|
11
|
+
date: 2019-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|