capybara-screenshot-diff 1.8.3 → 1.9.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 +4 -4
- data/Rakefile +1 -11
- data/capybara-screenshot-diff.gemspec +1 -2
- data/gems.rb +4 -4
- data/lib/capybara/screenshot/diff/area_calculator.rb +56 -0
- data/lib/capybara/screenshot/diff/browser_helpers.rb +1 -1
- data/lib/capybara/screenshot/diff/comparison.rb +6 -0
- data/lib/capybara/screenshot/diff/cucumber.rb +1 -9
- data/lib/capybara/screenshot/diff/difference.rb +8 -4
- data/lib/capybara/screenshot/diff/drivers/base_driver.rb +0 -4
- data/lib/capybara/screenshot/diff/drivers/chunky_png_driver.rb +10 -5
- data/lib/capybara/screenshot/diff/drivers/vips_driver.rb +14 -3
- data/lib/capybara/screenshot/diff/drivers.rb +1 -1
- data/lib/capybara/screenshot/diff/image_compare.rb +80 -114
- data/lib/capybara/screenshot/diff/region.rb +28 -7
- data/lib/capybara/screenshot/diff/reporters/default.rb +117 -0
- data/lib/capybara/screenshot/diff/screenshot_matcher.rb +24 -53
- data/lib/capybara/screenshot/diff/screenshoter.rb +61 -42
- data/lib/capybara/screenshot/diff/stable_screenshoter.rb +51 -29
- data/lib/capybara/screenshot/diff/test_methods.rb +75 -8
- data/lib/capybara/screenshot/diff/{drivers/utils.rb → utils.rb} +0 -7
- data/lib/capybara/screenshot/diff/vcs.rb +1 -1
- data/lib/capybara/screenshot/diff/version.rb +1 -1
- data/lib/capybara/screenshot/diff.rb +1 -111
- data/lib/capybara-screenshot-diff.rb +1 -1
- data/lib/capybara_screenshot_diff/cucumber.rb +12 -0
- data/lib/capybara_screenshot_diff/dsl.rb +10 -0
- data/lib/capybara_screenshot_diff/minitest.rb +45 -0
- data/lib/capybara_screenshot_diff/rspec.rb +31 -0
- data/lib/capybara_screenshot_diff.rb +85 -0
- metadata +15 -37
- data/lib/capybara/screenshot/diff/stabilization.rb +0 -0
- data/sig/capybara/screenshot/diff/diff.rbs +0 -28
- data/sig/capybara/screenshot/diff/difference.rbs +0 -33
- data/sig/capybara/screenshot/diff/drivers/base_driver.rbs +0 -63
- data/sig/capybara/screenshot/diff/drivers/browser_helpers.rbs +0 -36
- data/sig/capybara/screenshot/diff/drivers/chunky_png_driver.rbs +0 -89
- data/sig/capybara/screenshot/diff/drivers/utils.rbs +0 -13
- data/sig/capybara/screenshot/diff/drivers/vips_driver.rbs +0 -25
- data/sig/capybara/screenshot/diff/image_compare.rbs +0 -93
- data/sig/capybara/screenshot/diff/os.rbs +0 -11
- data/sig/capybara/screenshot/diff/region.rbs +0 -43
- data/sig/capybara/screenshot/diff/screenshot_matcher.rbs +0 -60
- data/sig/capybara/screenshot/diff/screenshoter.rbs +0 -48
- data/sig/capybara/screenshot/diff/stable_screenshoter.rbs +0 -29
- data/sig/capybara/screenshot/diff/test_methods.rbs +0 -39
- data/sig/capybara/screenshot/diff/vcs.rbs +0 -17
@@ -15,11 +15,20 @@ require_relative "region"
|
|
15
15
|
|
16
16
|
require_relative "screenshot_matcher"
|
17
17
|
|
18
|
-
#
|
18
|
+
# == Capybara::Screenshot::Diff::TestMethods
|
19
|
+
#
|
20
|
+
# This module provides methods for capturing screenshots and verifying them against
|
21
|
+
# baseline images to detect visual changes. It's designed to be included in test
|
22
|
+
# classes to add visual regression testing capabilities.
|
23
|
+
|
19
24
|
module Capybara
|
20
25
|
module Screenshot
|
21
26
|
module Diff
|
22
27
|
module TestMethods
|
28
|
+
# @!attribute [rw] test_screenshots
|
29
|
+
# @return [Array(Array(Array(String), String, ImageCompare))] An array where each element is an array containing the caller context,
|
30
|
+
# the name of the screenshot, and the comparison object. This attribute stores information about each screenshot
|
31
|
+
# scheduled for comparison to ensure they do not show any unintended differences.
|
23
32
|
def initialize(*)
|
24
33
|
super
|
25
34
|
@screenshot_counter = nil
|
@@ -29,6 +38,29 @@ module Capybara
|
|
29
38
|
@test_screenshots = []
|
30
39
|
end
|
31
40
|
|
41
|
+
# Verifies that all scheduled screenshots do not show any unintended differences.
|
42
|
+
#
|
43
|
+
# @param screenshots [Array(Array(Array(String), String, ImageCompare))] The list of match screenshots jobs. Defaults to all screenshots taken during the test.
|
44
|
+
# @return [Array, nil] Returns an array of error messages if there are screenshot differences, otherwise nil.
|
45
|
+
# @note This method is typically called at the end of a test to assert all screenshots are as expected.
|
46
|
+
def verify_screenshots!(screenshots = @test_screenshots)
|
47
|
+
return unless ::Capybara::Screenshot.active? && ::Capybara::Screenshot::Diff.fail_on_difference
|
48
|
+
|
49
|
+
test_screenshot_errors = screenshots.map do |caller, name, compare|
|
50
|
+
assert_image_not_changed(caller, name, compare)
|
51
|
+
end
|
52
|
+
|
53
|
+
test_screenshot_errors.compact!
|
54
|
+
|
55
|
+
test_screenshot_errors.presence
|
56
|
+
ensure
|
57
|
+
screenshots.clear
|
58
|
+
end
|
59
|
+
|
60
|
+
# Builds the full name for a screenshot, incorporating counters and group names for uniqueness.
|
61
|
+
#
|
62
|
+
# @param name [String] The base name for the screenshot.
|
63
|
+
# @return [String] The full, unique name for the screenshot.
|
32
64
|
def build_full_name(name)
|
33
65
|
if @screenshot_counter
|
34
66
|
name = format("%02i_#{name}", @screenshot_counter)
|
@@ -38,6 +70,9 @@ module Capybara
|
|
38
70
|
File.join(*group_parts.push(name.to_s))
|
39
71
|
end
|
40
72
|
|
73
|
+
# Determines the directory path for saving screenshots.
|
74
|
+
#
|
75
|
+
# @return [String] The full path to the directory where screenshots are saved.
|
41
76
|
def screenshot_dir
|
42
77
|
File.join(*([Screenshot.screenshot_area] + group_parts))
|
43
78
|
end
|
@@ -54,6 +89,13 @@ module Capybara
|
|
54
89
|
FileUtils.rm_rf screenshot_dir
|
55
90
|
end
|
56
91
|
|
92
|
+
# Schedules a screenshot comparison job for later execution.
|
93
|
+
#
|
94
|
+
# This method adds a job to the queue of screenshots to be matched. It's used when `Capybara::Screenshot::Diff.delayed`
|
95
|
+
# is set to true, allowing for batch processing of screenshot comparisons at a later point, typically at the end of a test.
|
96
|
+
#
|
97
|
+
# @param job [Array(Array(String), String, ImageCompare)] The job to be scheduled, consisting of the caller context, screenshot name, and comparison object.
|
98
|
+
# @return [Boolean] Always returns true, indicating the job was successfully scheduled.
|
57
99
|
def schedule_match_job(job)
|
58
100
|
(@test_screenshots ||= []) << job
|
59
101
|
true
|
@@ -66,28 +108,49 @@ module Capybara
|
|
66
108
|
parts
|
67
109
|
end
|
68
110
|
|
111
|
+
# Takes a screenshot and optionally compares it against a baseline image.
|
112
|
+
#
|
113
|
+
# @param name [String] The name of the screenshot, used to generate the filename.
|
114
|
+
# @param skip_stack_frames [Integer] The number of stack frames to skip when reporting errors, for cleaner error messages.
|
115
|
+
# @param options [Hash] Additional options for taking the screenshot, such as custom dimensions or selectors.
|
116
|
+
# @return [Boolean] Returns true if the screenshot was successfully captured and matches the baseline, false otherwise.
|
117
|
+
# @raise [CapybaraScreenshotDiff::ExpectationNotMet] If the screenshot does not match the baseline image and fail_if_new is set to true.
|
118
|
+
# @example Capture a full-page screenshot named 'login_page'
|
119
|
+
# screenshot('login_page', skip_stack_frames: 1, full: true)
|
69
120
|
def screenshot(name, skip_stack_frames: 0, **options)
|
70
121
|
return false unless Screenshot.active?
|
71
122
|
|
72
123
|
screenshot_full_name = build_full_name(name)
|
73
124
|
job = build_screenshot_matches_job(screenshot_full_name, options)
|
74
125
|
|
75
|
-
|
126
|
+
unless job
|
127
|
+
if Screenshot::Diff.fail_if_new
|
128
|
+
raise_error(<<-ERROR.strip_heredoc, caller(2))
|
129
|
+
No existing screenshot found for #{screenshot_full_name}!
|
130
|
+
To stop seeing this error disable by `Capybara::Screenshot::Diff.fail_if_new=false`
|
131
|
+
ERROR
|
132
|
+
end
|
133
|
+
|
134
|
+
return false
|
135
|
+
end
|
76
136
|
|
77
|
-
job.prepend(caller
|
137
|
+
job.prepend(caller(skip_stack_frames))
|
78
138
|
|
79
139
|
if Screenshot::Diff.delayed
|
80
140
|
schedule_match_job(job)
|
81
141
|
else
|
82
142
|
error_msg = assert_image_not_changed(*job)
|
83
|
-
if error_msg
|
84
|
-
error = ASSERTION.new(error_msg)
|
85
|
-
error.set_backtrace(caller(2))
|
86
|
-
raise error
|
87
|
-
end
|
143
|
+
raise_error(error_msg, caller(2)) if error_msg
|
88
144
|
end
|
89
145
|
end
|
90
146
|
|
147
|
+
# Asserts that an image has not changed compared to its baseline.
|
148
|
+
#
|
149
|
+
# @param caller [Array] The caller context, used for error reporting.
|
150
|
+
# @param name [String] The name of the screenshot being verified.
|
151
|
+
# @param comparison [Object] The comparison object containing the result and details of the comparison.
|
152
|
+
# @return [String, nil] Returns an error message if the screenshot differs from the baseline, otherwise nil.
|
153
|
+
# @note This method is used internally to verify individual screenshots.
|
91
154
|
def assert_image_not_changed(caller, name, comparison)
|
92
155
|
result = comparison.different?
|
93
156
|
|
@@ -105,6 +168,10 @@ module Capybara
|
|
105
168
|
|
106
169
|
private
|
107
170
|
|
171
|
+
def raise_error(error_msg, backtrace)
|
172
|
+
raise CapybaraScreenshotDiff::ExpectationNotMet.new(error_msg).tap { _1.set_backtrace(backtrace) }
|
173
|
+
end
|
174
|
+
|
108
175
|
def build_screenshot_matches_job(screenshot_full_name, options)
|
109
176
|
ScreenshotMatcher
|
110
177
|
.new(screenshot_full_name, options)
|
@@ -36,13 +36,6 @@ module Capybara
|
|
36
36
|
fail "Wrong adapter #{driver.inspect}. Available adapters: #{AVAILABLE_DRIVERS.inspect}"
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
40
|
-
def self.detect_test_framework_assert
|
41
|
-
require "minitest"
|
42
|
-
::Minitest::Assertion
|
43
|
-
rescue
|
44
|
-
::RuntimeError
|
45
|
-
end
|
46
39
|
end
|
47
40
|
end
|
48
41
|
end
|
@@ -1,113 +1,3 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "capybara/screenshot/diff/version"
|
5
|
-
require "capybara/screenshot/diff/drivers/utils"
|
6
|
-
require "capybara/screenshot/diff/image_compare"
|
7
|
-
require "capybara/screenshot/diff/test_methods"
|
8
|
-
require "capybara/screenshot/diff/screenshoter"
|
9
|
-
|
10
|
-
module Capybara
|
11
|
-
module Screenshot
|
12
|
-
mattr_accessor :add_driver_path
|
13
|
-
mattr_accessor :add_os_path
|
14
|
-
mattr_accessor :blur_active_element
|
15
|
-
mattr_accessor :enabled
|
16
|
-
mattr_accessor :hide_caret
|
17
|
-
mattr_reader(:root) { (defined?(Rails.root) && Rails.root) || Pathname(".").expand_path }
|
18
|
-
mattr_accessor :stability_time_limit
|
19
|
-
mattr_accessor :window_size
|
20
|
-
mattr_accessor(:save_path) { "doc/screenshots" }
|
21
|
-
mattr_accessor(:use_lfs)
|
22
|
-
|
23
|
-
class << self
|
24
|
-
def root=(path)
|
25
|
-
@@root = Pathname(path).expand_path
|
26
|
-
end
|
27
|
-
|
28
|
-
def active?
|
29
|
-
enabled || (enabled.nil? && Diff.enabled)
|
30
|
-
end
|
31
|
-
|
32
|
-
def screenshot_area
|
33
|
-
parts = [Screenshot.save_path]
|
34
|
-
parts << Capybara.current_driver.to_s if Screenshot.add_driver_path
|
35
|
-
parts << Os.name if Screenshot.add_os_path
|
36
|
-
File.join(*parts)
|
37
|
-
end
|
38
|
-
|
39
|
-
def screenshot_area_abs
|
40
|
-
root / screenshot_area
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Module to track screen shot changes
|
45
|
-
module Diff
|
46
|
-
include Capybara::DSL
|
47
|
-
|
48
|
-
mattr_accessor(:delayed) { true }
|
49
|
-
mattr_accessor :area_size_limit
|
50
|
-
mattr_accessor :color_distance_limit
|
51
|
-
mattr_accessor(:enabled) { true }
|
52
|
-
mattr_accessor :shift_distance_limit
|
53
|
-
mattr_accessor :skip_area
|
54
|
-
mattr_accessor(:driver) { :auto }
|
55
|
-
mattr_accessor :tolerance
|
56
|
-
|
57
|
-
mattr_accessor(:screenshoter) { Screenshoter }
|
58
|
-
|
59
|
-
AVAILABLE_DRIVERS = Utils.detect_available_drivers.freeze
|
60
|
-
ASSERTION = Utils.detect_test_framework_assert
|
61
|
-
|
62
|
-
def self.default_options
|
63
|
-
{
|
64
|
-
area_size_limit: area_size_limit,
|
65
|
-
color_distance_limit: color_distance_limit,
|
66
|
-
driver: driver,
|
67
|
-
shift_distance_limit: shift_distance_limit,
|
68
|
-
skip_area: skip_area,
|
69
|
-
stability_time_limit: Screenshot.stability_time_limit,
|
70
|
-
tolerance: tolerance || ((driver == :vips) ? 0.001 : nil),
|
71
|
-
wait: Capybara.default_max_wait_time
|
72
|
-
}
|
73
|
-
end
|
74
|
-
|
75
|
-
def self.included(klass)
|
76
|
-
klass.include TestMethods
|
77
|
-
klass.setup do
|
78
|
-
BrowserHelpers.resize_to(Screenshot.window_size) if Screenshot.window_size
|
79
|
-
end
|
80
|
-
|
81
|
-
klass.teardown do
|
82
|
-
if Screenshot.active? && @test_screenshots.present?
|
83
|
-
track_failures(@test_screenshots)
|
84
|
-
@test_screenshots.clear
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
private
|
90
|
-
|
91
|
-
EMPTY_LINE = "\n\n"
|
92
|
-
|
93
|
-
def track_failures(screenshots)
|
94
|
-
test_screenshot_errors = screenshots.map do |caller, name, compare|
|
95
|
-
assert_image_not_changed(caller, name, compare)
|
96
|
-
end
|
97
|
-
|
98
|
-
test_screenshot_errors.compact!
|
99
|
-
|
100
|
-
unless test_screenshot_errors.empty?
|
101
|
-
error = ASSERTION.new(test_screenshot_errors.join(EMPTY_LINE))
|
102
|
-
error.set_backtrace([])
|
103
|
-
|
104
|
-
if is_a?(::Minitest::Runnable)
|
105
|
-
failures << error
|
106
|
-
else
|
107
|
-
raise error
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
3
|
+
require "capybara_screenshot_diff/minitest"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "capybara_screenshot_diff/dsl"
|
4
|
+
|
5
|
+
World(::CapybaraScreenshotDiff::DSL)
|
6
|
+
|
7
|
+
Before do
|
8
|
+
Capybara::Screenshot::Diff.delayed = false
|
9
|
+
if Capybara::Screenshot.active? && Capybara::Screenshot.window_size
|
10
|
+
Capybara::Screenshot::BrowserHelpers.resize_to(Capybara::Screenshot.window_size)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "minitest"
|
4
|
+
require "capybara_screenshot_diff/dsl"
|
5
|
+
|
6
|
+
used_deprecated_entrypoint = caller.any? do |path|
|
7
|
+
path.include?("capybara-screenshot-diff.rb") || path.include?("capybara/screenshot/diff.rb")
|
8
|
+
end
|
9
|
+
|
10
|
+
if used_deprecated_entrypoint
|
11
|
+
warn <<~MSG
|
12
|
+
[DEPRECATION] The default activation of `capybara_screenshot_diff/minitest` will be removed.
|
13
|
+
Please `require "capybara_screenshot_diff/minitest"` explicitly.
|
14
|
+
MSG
|
15
|
+
end
|
16
|
+
|
17
|
+
module CapybaraScreenshotDiff
|
18
|
+
module Minitest
|
19
|
+
module Assertions
|
20
|
+
include ::CapybaraScreenshotDiff::DSL
|
21
|
+
|
22
|
+
def screenshot(*, **)
|
23
|
+
super
|
24
|
+
rescue CapybaraScreenshotDiff::ExpectationNotMet => e
|
25
|
+
raise ::Minitest::Assertion, e.message
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_method :assert_matches_screenshot, :screenshot
|
29
|
+
|
30
|
+
def self.included(klass)
|
31
|
+
klass.setup do
|
32
|
+
if ::Capybara::Screenshot.window_size
|
33
|
+
::Capybara::Screenshot::BrowserHelpers.resize_to(::Capybara::Screenshot.window_size)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
klass.teardown do
|
38
|
+
errors = verify_screenshots!(@test_screenshots)
|
39
|
+
|
40
|
+
failures << ::Minitest::Assertion.new(errors.join("\n\n")) if errors && !errors.empty?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rspec/core"
|
4
|
+
require "capybara_screenshot_diff/dsl"
|
5
|
+
|
6
|
+
RSpec::Matchers.define :match_screenshot do |name, **options|
|
7
|
+
description { "match a screenshot" }
|
8
|
+
|
9
|
+
match do |_page|
|
10
|
+
screenshot(name, **options)
|
11
|
+
true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.include ::CapybaraScreenshotDiff::DSL, type: :feature
|
17
|
+
|
18
|
+
config.after do
|
19
|
+
if self.class.include?(::CapybaraScreenshotDiff::DSL) && ::Capybara::Screenshot.active?
|
20
|
+
errors = verify_screenshots!(@test_screenshots)
|
21
|
+
# TODO: Use rspec/mock approach to postpone verification
|
22
|
+
raise ::CapybaraScreenshotDiff::ExpectationNotMet, errors.join("\n") if errors && !errors.empty?
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
config.before do
|
27
|
+
if self.class.include?(::CapybaraScreenshotDiff::DSL) && ::Capybara::Screenshot.window_size
|
28
|
+
::Capybara::Screenshot::BrowserHelpers.resize_to(::Capybara::Screenshot.window_size)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "capybara/dsl"
|
4
|
+
require "capybara/screenshot/diff/version"
|
5
|
+
require "capybara/screenshot/diff/utils"
|
6
|
+
require "capybara/screenshot/diff/image_compare"
|
7
|
+
require "capybara/screenshot/diff/test_methods"
|
8
|
+
require "capybara/screenshot/diff/screenshoter"
|
9
|
+
|
10
|
+
require "capybara/screenshot/diff/reporters/default"
|
11
|
+
|
12
|
+
module CapybaraScreenshotDiff
|
13
|
+
class ExpectationNotMet < StandardError; end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Capybara
|
17
|
+
module Screenshot
|
18
|
+
mattr_accessor :add_driver_path
|
19
|
+
mattr_accessor :add_os_path
|
20
|
+
mattr_accessor :blur_active_element
|
21
|
+
mattr_accessor :enabled
|
22
|
+
mattr_accessor :hide_caret
|
23
|
+
mattr_reader(:root) { (defined?(Rails.root) && Rails.root) || Pathname(".").expand_path }
|
24
|
+
mattr_accessor :stability_time_limit
|
25
|
+
mattr_accessor :window_size
|
26
|
+
mattr_accessor(:save_path) { "doc/screenshots" }
|
27
|
+
mattr_accessor(:use_lfs)
|
28
|
+
mattr_accessor(:screenshot_format) { "png" }
|
29
|
+
mattr_accessor(:capybara_screenshot_options) { {} }
|
30
|
+
|
31
|
+
class << self
|
32
|
+
def root=(path)
|
33
|
+
@@root = Pathname(path).expand_path
|
34
|
+
end
|
35
|
+
|
36
|
+
def active?
|
37
|
+
enabled || (enabled.nil? && Diff.enabled)
|
38
|
+
end
|
39
|
+
|
40
|
+
def screenshot_area
|
41
|
+
parts = [Screenshot.save_path]
|
42
|
+
parts << Os.name if Screenshot.add_os_path
|
43
|
+
parts << Capybara.current_driver.to_s if Screenshot.add_driver_path
|
44
|
+
File.join(*parts)
|
45
|
+
end
|
46
|
+
|
47
|
+
def screenshot_area_abs
|
48
|
+
root / screenshot_area
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Module to track screen shot changes
|
53
|
+
module Diff
|
54
|
+
mattr_accessor(:delayed) { true }
|
55
|
+
mattr_accessor :area_size_limit
|
56
|
+
mattr_accessor(:fail_if_new) { false }
|
57
|
+
mattr_accessor(:fail_on_difference) { true }
|
58
|
+
mattr_accessor :color_distance_limit
|
59
|
+
mattr_accessor(:enabled) { true }
|
60
|
+
mattr_accessor :shift_distance_limit
|
61
|
+
mattr_accessor :skip_area
|
62
|
+
mattr_accessor(:driver) { :auto }
|
63
|
+
mattr_accessor :tolerance
|
64
|
+
|
65
|
+
mattr_accessor(:screenshoter) { Screenshoter }
|
66
|
+
|
67
|
+
AVAILABLE_DRIVERS = Utils.detect_available_drivers.freeze
|
68
|
+
|
69
|
+
def self.default_options
|
70
|
+
{
|
71
|
+
area_size_limit: area_size_limit,
|
72
|
+
color_distance_limit: color_distance_limit,
|
73
|
+
driver: driver,
|
74
|
+
screenshot_format: Screenshot.screenshot_format,
|
75
|
+
capybara_screenshot_options: Screenshot.capybara_screenshot_options,
|
76
|
+
shift_distance_limit: shift_distance_limit,
|
77
|
+
skip_area: skip_area,
|
78
|
+
stability_time_limit: Screenshot.stability_time_limit,
|
79
|
+
tolerance: tolerance || ((driver == :vips) ? 0.001 : nil),
|
80
|
+
wait: Capybara.default_max_wait_time
|
81
|
+
}
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
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.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uwe Kubosch
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -50,20 +50,6 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '4'
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: chunky_png
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '1.3'
|
60
|
-
type: :runtime
|
61
|
-
prerelease: false
|
62
|
-
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - "~>"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '1.3'
|
67
53
|
description: Save screen shots and track changes with graphical diff
|
68
54
|
email:
|
69
55
|
- uwe@kubosch.no
|
@@ -77,45 +63,37 @@ files:
|
|
77
63
|
- gems.rb
|
78
64
|
- lib/capybara-screenshot-diff.rb
|
79
65
|
- lib/capybara/screenshot/diff.rb
|
66
|
+
- lib/capybara/screenshot/diff/area_calculator.rb
|
80
67
|
- lib/capybara/screenshot/diff/browser_helpers.rb
|
68
|
+
- lib/capybara/screenshot/diff/comparison.rb
|
81
69
|
- lib/capybara/screenshot/diff/cucumber.rb
|
82
70
|
- lib/capybara/screenshot/diff/difference.rb
|
83
71
|
- lib/capybara/screenshot/diff/drivers.rb
|
84
72
|
- lib/capybara/screenshot/diff/drivers/base_driver.rb
|
85
73
|
- lib/capybara/screenshot/diff/drivers/chunky_png_driver.rb
|
86
|
-
- lib/capybara/screenshot/diff/drivers/utils.rb
|
87
74
|
- lib/capybara/screenshot/diff/drivers/vips_driver.rb
|
88
75
|
- lib/capybara/screenshot/diff/image_compare.rb
|
89
76
|
- lib/capybara/screenshot/diff/os.rb
|
90
77
|
- lib/capybara/screenshot/diff/region.rb
|
78
|
+
- lib/capybara/screenshot/diff/reporters/default.rb
|
91
79
|
- lib/capybara/screenshot/diff/screenshot_matcher.rb
|
92
80
|
- lib/capybara/screenshot/diff/screenshoter.rb
|
93
|
-
- lib/capybara/screenshot/diff/stabilization.rb
|
94
81
|
- lib/capybara/screenshot/diff/stable_screenshoter.rb
|
95
82
|
- lib/capybara/screenshot/diff/test_methods.rb
|
83
|
+
- lib/capybara/screenshot/diff/utils.rb
|
96
84
|
- lib/capybara/screenshot/diff/vcs.rb
|
97
85
|
- lib/capybara/screenshot/diff/version.rb
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
101
|
-
-
|
102
|
-
-
|
103
|
-
- sig/capybara/screenshot/diff/drivers/utils.rbs
|
104
|
-
- sig/capybara/screenshot/diff/drivers/vips_driver.rbs
|
105
|
-
- sig/capybara/screenshot/diff/image_compare.rbs
|
106
|
-
- sig/capybara/screenshot/diff/os.rbs
|
107
|
-
- sig/capybara/screenshot/diff/region.rbs
|
108
|
-
- sig/capybara/screenshot/diff/screenshot_matcher.rbs
|
109
|
-
- sig/capybara/screenshot/diff/screenshoter.rbs
|
110
|
-
- sig/capybara/screenshot/diff/stable_screenshoter.rbs
|
111
|
-
- sig/capybara/screenshot/diff/test_methods.rbs
|
112
|
-
- sig/capybara/screenshot/diff/vcs.rbs
|
86
|
+
- lib/capybara_screenshot_diff.rb
|
87
|
+
- lib/capybara_screenshot_diff/cucumber.rb
|
88
|
+
- lib/capybara_screenshot_diff/dsl.rb
|
89
|
+
- lib/capybara_screenshot_diff/minitest.rb
|
90
|
+
- lib/capybara_screenshot_diff/rspec.rb
|
113
91
|
homepage: https://github.com/donv/capybara-screenshot-diff
|
114
92
|
licenses:
|
115
93
|
- MIT
|
116
94
|
metadata:
|
117
95
|
allowed_push_host: https://rubygems.org/
|
118
|
-
post_install_message:
|
96
|
+
post_install_message:
|
119
97
|
rdoc_options: []
|
120
98
|
require_paths:
|
121
99
|
- lib
|
@@ -130,8 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
108
|
- !ruby/object:Gem::Version
|
131
109
|
version: '0'
|
132
110
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
134
|
-
signing_key:
|
111
|
+
rubygems_version: 3.5.11
|
112
|
+
signing_key:
|
135
113
|
specification_version: 4
|
136
114
|
summary: Track your GUI changes with diff assertions
|
137
115
|
test_files: []
|
File without changes
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Capybara
|
2
|
-
module Screenshot
|
3
|
-
def self.root=: ((String | Pathname) path) -> Pathname
|
4
|
-
|
5
|
-
def self.root: -> Pathname
|
6
|
-
|
7
|
-
def self.active?: () -> boolish
|
8
|
-
|
9
|
-
def self.screenshot_area: () -> String
|
10
|
-
|
11
|
-
def self.screenshot_area_abs: () -> Pathname
|
12
|
-
|
13
|
-
# Module to track screen shot changes
|
14
|
-
module Diff
|
15
|
-
AVAILABLE_DRIVERS: Array[(:vips | :chunky_png)]
|
16
|
-
|
17
|
-
ASSERTION: (top | RuntimeError)
|
18
|
-
|
19
|
-
def self.default_options: () -> ScreenshotMatcher::input_options
|
20
|
-
|
21
|
-
def self.included: (top klass) -> void
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def track_failures: (Array[untyped] screenshots) -> void
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Capybara
|
2
|
-
module Screenshot
|
3
|
-
module Diff
|
4
|
-
class Difference
|
5
|
-
attr_reader comparison: ImageCompare::Comparison
|
6
|
-
|
7
|
-
def different?: () -> bool
|
8
|
-
|
9
|
-
def base_image: () -> top
|
10
|
-
|
11
|
-
def options: () -> Drivers::BaseDriver::options_entity
|
12
|
-
|
13
|
-
def tolerance: () -> Numeric?
|
14
|
-
|
15
|
-
def area_size_limit: () -> Numeric?
|
16
|
-
|
17
|
-
def blank?: () -> bool
|
18
|
-
|
19
|
-
def region_area_size: () -> Numeric
|
20
|
-
|
21
|
-
def ratio: () -> Numeric?
|
22
|
-
|
23
|
-
def to_h: () -> Hash[Symbol, untyped]
|
24
|
-
|
25
|
-
def coordinates: () -> Region::raw_region_entity
|
26
|
-
|
27
|
-
def inspect: () -> String
|
28
|
-
|
29
|
-
def tolerable?: () -> bool
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|