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
-
#base_screenshot_path ⇒ Object
readonly
Returns the value of attribute base_screenshot_path.
-
#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.
-
#screenshot_path ⇒ Object
readonly
Returns the value of attribute screenshot_path.
Class Method Summary collapse
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.
15 16 17 18 19 20 21 22 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 15 def initialize(screenshot_full_name, = {}) @screenshot_full_name = screenshot_full_name = Diff..merge() @screenshot_format = [:screenshot_format] @screenshot_path = Screenshot.screenshot_area_abs / Pathname.new(screenshot_full_name).sub_ext(".#{screenshot_format}") @base_screenshot_path = ScreenshotMatcher.base_image_path_from(@screenshot_path) end |
Instance Attribute Details
#base_screenshot_path ⇒ Object (readonly)
Returns the value of attribute base_screenshot_path.
13 14 15 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 13 def base_screenshot_path @base_screenshot_path end |
#driver_options ⇒ Object (readonly)
Returns the value of attribute driver_options.
13 14 15 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 13 def end |
#screenshot_format ⇒ Object (readonly)
Returns the value of attribute screenshot_format.
13 14 15 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 13 def screenshot_format @screenshot_format end |
#screenshot_full_name ⇒ Object (readonly)
Returns the value of attribute screenshot_full_name.
13 14 15 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 13 def screenshot_full_name @screenshot_full_name end |
#screenshot_path ⇒ Object (readonly)
Returns the value of attribute screenshot_path.
13 14 15 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 13 def screenshot_path @screenshot_path end |
Class Method Details
.base_image_path_from(screenshot_path) ⇒ Object
67 68 69 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 67 def self.base_image_path_from(screenshot_path) screenshot_path.sub_ext(".base#{screenshot_path.extname}") 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 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# 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]) # Load base screenshot from VCS create_output_directory_for(screenshot_path) unless screenshot_path.exist? checkout_base_screenshot # When fail_if_new is true no need to create screenshot if base screenshot is missing return if ::Screenshot::Diff.fail_if_new && !base_screenshot_path.exist? = { # screenshot options capybara_screenshot_options: [:capybara_screenshot_options], crop: .delete(:crop), # delivery options screenshot_format: [:screenshot_format], # stability options stability_time_limit: .delete(:stability_time_limit), wait: .delete(:wait) } # Load new screenshot from Browser take_comparison_screenshot(, , screenshot_path) # Pre-computation: No need to compare without base screenshot return unless base_screenshot_path.exist? # Add comparison job in the queue [screenshot_full_name, ImageCompare.new(screenshot_path, base_screenshot_path, )] end |