capybara-screenshot-diff 1.6.0 → 1.6.3
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 +4 -4
- data/.github/workflows/test.yml +2 -2
- data/lib/capybara/screenshot/diff/drivers/chunky_png_driver.rb +2 -2
- data/lib/capybara/screenshot/diff/drivers/utils.rb +7 -0
- data/lib/capybara/screenshot/diff/drivers/vips_driver.rb +8 -2
- data/lib/capybara/screenshot/diff/stabilization.rb +7 -9
- data/lib/capybara/screenshot/diff/version.rb +1 -1
- data/lib/capybara/screenshot/diff.rb +28 -17
- 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: ecb7108c89946f6489787b491c0cd831f096d09ee656e68674887952682aee7a
|
|
4
|
+
data.tar.gz: d41e23dae6a64663d26b586235ccc4cdc10d02a43b3fefa6a8563327cde563bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 89501dc8c7ab1b540d182dacd10f8bf2d3b24521851db20bed42eb7c066b484d5a5cfbc766a4a0d5c80539500c1eef342f55be4069da455ba1d2ba14524d2463
|
|
7
|
+
data.tar.gz: 12c02e086af0df03206eaa5ac332306b0b199c33d70b6393c64a60a70a5777e4598b4aedf67afc0a6aa06166247efd7e6a0c21652aa4c2587e13009566363b87
|
data/.github/workflows/test.yml
CHANGED
|
@@ -115,7 +115,7 @@ module Capybara
|
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
def crop(dimensions, i)
|
|
118
|
-
i.crop(
|
|
118
|
+
i.crop(*dimensions)
|
|
119
119
|
end
|
|
120
120
|
|
|
121
121
|
def from_file(filename)
|
|
@@ -135,7 +135,7 @@ module Capybara
|
|
|
135
135
|
|
|
136
136
|
old_image, new_image = _load_images(old_file, new_file)
|
|
137
137
|
calculate_max_color_distance(new_image, old_image)
|
|
138
|
-
calculate_max_shift_limit(new_image, old_image)
|
|
138
|
+
calculate_max_shift_limit(new_image, old_image) if @shift_distance_limit
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
def calculate_max_color_distance(new_image, old_image)
|
|
@@ -69,7 +69,7 @@ module Capybara
|
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
def crop(dimensions, i)
|
|
72
|
-
i.crop(
|
|
72
|
+
i.crop(*dimensions)
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
def filter_image_with_median(image, median_filter_window_size)
|
|
@@ -104,8 +104,14 @@ module Capybara
|
|
|
104
104
|
image.width
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
+
PNG_EXTENSION = ".png"
|
|
108
|
+
|
|
109
|
+
# Vips could not work with the same file. Per each process we require to create new file
|
|
107
110
|
def save_image_to(image, filename)
|
|
108
|
-
|
|
111
|
+
::Dir::Tmpname.create([filename, PNG_EXTENSION]) do |tmp_image_filename|
|
|
112
|
+
image.write_to_file(tmp_image_filename)
|
|
113
|
+
FileUtils.mv(tmp_image_filename, filename)
|
|
114
|
+
end
|
|
109
115
|
end
|
|
110
116
|
|
|
111
117
|
def resize_image_to(image, new_width, new_height)
|
|
@@ -110,11 +110,7 @@ module Capybara
|
|
|
110
110
|
new_height = expected_image_width * driver.height_for(saved_image) / driver.width_for(saved_image)
|
|
111
111
|
resized_image = driver.resize_image_to(saved_image, expected_image_width, new_height)
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
resized_image_file = "#{dir}/resized.png"
|
|
115
|
-
driver.save_image_to(resized_image, resized_image_file)
|
|
116
|
-
FileUtils.mv(resized_image_file, file_name)
|
|
117
|
-
end
|
|
113
|
+
driver.save_image_to(resized_image, file_name)
|
|
118
114
|
end
|
|
119
115
|
|
|
120
116
|
def stabilization_images(base_file)
|
|
@@ -143,16 +139,18 @@ module Capybara
|
|
|
143
139
|
end
|
|
144
140
|
|
|
145
141
|
def take_right_size_screenshot(comparison, crop:)
|
|
142
|
+
driver = comparison.driver
|
|
143
|
+
|
|
146
144
|
save_screenshot(comparison.new_file_name)
|
|
147
145
|
|
|
148
146
|
# TODO(uwe): Remove when chromedriver takes right size screenshots
|
|
149
|
-
reduce_retina_image_size(comparison.new_file_name,
|
|
147
|
+
reduce_retina_image_size(comparison.new_file_name, driver)
|
|
150
148
|
# ODOT
|
|
151
149
|
|
|
152
150
|
if crop
|
|
153
|
-
full_img =
|
|
154
|
-
area_img =
|
|
155
|
-
|
|
151
|
+
full_img = driver.from_file(comparison.new_file_name)
|
|
152
|
+
area_img = driver.crop([crop[0], crop[1], crop[2] - crop[0], crop[3] - crop[1]], full_img)
|
|
153
|
+
driver.save_image_to(area_img, comparison.new_file_name)
|
|
156
154
|
end
|
|
157
155
|
end
|
|
158
156
|
|
|
@@ -52,15 +52,10 @@ module Capybara
|
|
|
52
52
|
mattr_accessor :shift_distance_limit
|
|
53
53
|
mattr_accessor :skip_area
|
|
54
54
|
mattr_accessor(:driver) { :auto }
|
|
55
|
-
mattr_accessor
|
|
55
|
+
mattr_accessor :tolerance
|
|
56
56
|
|
|
57
57
|
AVAILABLE_DRIVERS = Utils.detect_available_drivers.freeze
|
|
58
|
-
|
|
59
|
-
require "minitest"
|
|
60
|
-
ASSERTION = Minitest::Assertion
|
|
61
|
-
rescue
|
|
62
|
-
ASSERTION = RuntimeError
|
|
63
|
-
end
|
|
58
|
+
ASSERTION = Utils.detect_test_framework_assert
|
|
64
59
|
|
|
65
60
|
def self.default_options
|
|
66
61
|
{
|
|
@@ -70,7 +65,7 @@ module Capybara
|
|
|
70
65
|
shift_distance_limit: shift_distance_limit,
|
|
71
66
|
skip_area: skip_area,
|
|
72
67
|
stability_time_limit: Screenshot.stability_time_limit,
|
|
73
|
-
tolerance: tolerance,
|
|
68
|
+
tolerance: tolerance || (driver == :vips ? 0.001 : nil),
|
|
74
69
|
wait: Capybara.default_max_wait_time
|
|
75
70
|
}
|
|
76
71
|
end
|
|
@@ -89,15 +84,31 @@ module Capybara
|
|
|
89
84
|
|
|
90
85
|
klass.teardown do
|
|
91
86
|
if Capybara::Screenshot.active? && @test_screenshots
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
87
|
+
track_failures(@test_screenshots, caller)
|
|
88
|
+
@test_screenshots = nil
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
private
|
|
94
|
+
|
|
95
|
+
EMPTY_LINE = "\n\n"
|
|
96
|
+
|
|
97
|
+
def track_failures(screenshots, original_caller)
|
|
98
|
+
test_screenshot_errors = screenshots.map do |caller, name, compare|
|
|
99
|
+
assert_image_not_changed(caller, name, compare)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
test_screenshot_errors.compact!
|
|
103
|
+
|
|
104
|
+
unless test_screenshot_errors.empty?
|
|
105
|
+
error = ASSERTION.new(test_screenshot_errors.join(EMPTY_LINE))
|
|
106
|
+
error.set_backtrace(original_caller)
|
|
107
|
+
|
|
108
|
+
if is_a?(::Minitest::Runnable)
|
|
109
|
+
failures << error
|
|
110
|
+
else
|
|
111
|
+
raise error
|
|
101
112
|
end
|
|
102
113
|
end
|
|
103
114
|
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: 1.6.
|
|
4
|
+
version: 1.6.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Uwe Kubosch
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-06-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionpack
|