Class: Capybara::Screenshot::Diff::ScreenshotMatcher
- Inherits:
-
Object
- Object
- Capybara::Screenshot::Diff::ScreenshotMatcher
- Defined in:
- lib/capybara/screenshot/diff/screenshot_matcher.rb
Instance Attribute Summary collapse
-
#driver_options ⇒ Object
readonly
Returns the value of attribute driver_options.
-
#screenshot_format ⇒ Object
readonly
Returns the value of attribute screenshot_format.
-
#screenshot_full_name ⇒ Object
readonly
Returns the value of attribute screenshot_full_name.
Instance Method Summary collapse
- #build_screenshot_matches_job ⇒ Object
-
#initialize(screenshot_full_name, options = {}) ⇒ ScreenshotMatcher
constructor
A new instance of ScreenshotMatcher.
Constructor Details
#initialize(screenshot_full_name, options = {}) ⇒ ScreenshotMatcher
Returns a new instance of ScreenshotMatcher.
16 17 18 19 20 21 22 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 16 def initialize(screenshot_full_name, = {}) @screenshot_full_name = screenshot_full_name @driver_options = Diff..merge() @screenshot_format = @driver_options[:screenshot_format] @snapshot = CapybaraScreenshotDiff::SnapManager.snapshot(screenshot_full_name, @screenshot_format) end |
Instance Attribute Details
#driver_options ⇒ Object (readonly)
Returns the value of attribute driver_options.
14 15 16 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 14 def @driver_options end |
#screenshot_format ⇒ Object (readonly)
Returns the value of attribute screenshot_format.
14 15 16 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 14 def screenshot_format @screenshot_format end |
#screenshot_full_name ⇒ Object (readonly)
Returns the value of attribute screenshot_full_name.
14 15 16 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 14 def screenshot_full_name @screenshot_full_name end |
Instance Method Details
#build_screenshot_matches_job ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 24 def build_screenshot_matches_job # TODO: Move this into screenshot stage, in order to re-evaluate coordinates after page updates return if BrowserHelpers.window_size_is_wrong?(Screenshot.window_size) # TODO: Move this into screenshot stage, in order to re-evaluate coordinates after page updates area_calculator = AreaCalculator.new(.delete(:crop), [:skip_area]) [:crop] = area_calculator.calculate_crop # TODO: Move this into screenshot stage, in order to re-evaluate coordinates after page updates # Allow nil or single or multiple areas [:skip_area] = area_calculator.calculate_skip_area [:driver] = Drivers.for([:driver]) @snapshot.checkout_base_screenshot # When fail_if_new is true no need to create screenshot if base screenshot is missing return if Capybara::Screenshot::Diff.fail_if_new && !@snapshot.base_path.exist? , = () # Load new screenshot from Browser take_comparison_screenshot(, , @snapshot) # Pre-computation: No need to compare without base screenshot return unless @snapshot.base_path.exist? # Add comparison job in the queue [screenshot_full_name, ImageCompare.new(@snapshot.path, @snapshot.base_path, )] end |