Module: Capybara::Screenshot::Diff

Includes:
DSL, Os
Defined in:
lib/capybara/screenshot/diff.rb,
lib/capybara/screenshot/diff/vcs.rb,
lib/capybara/screenshot/diff/version.rb,
lib/capybara/screenshot/diff/test_methods.rb,
lib/capybara/screenshot/diff/drivers/utils.rb,
lib/capybara/screenshot/diff/image_compare.rb,
lib/capybara/screenshot/diff/stabilization.rb,
lib/capybara/screenshot/diff/drivers/vips_driver.rb,
lib/capybara/screenshot/diff/drivers/chunky_png_driver.rb

Overview

Module to track screen shot changes

Defined Under Namespace

Modules: Drivers, Stabilization, TestMethods, Utils, Vcs Classes: ImageCompare

Constant Summary collapse

AVAILABLE_DRIVERS =
Utils.detect_available_drivers.freeze
VERSION =
"1.5.4"
LOADED_DRIVERS =
{}

Constants included from Os

Os::ON_LINUX, Os::ON_MAC, Os::ON_WINDOWS

Class Method Summary collapse

Methods included from Os

#os_name

Class Method Details

.included(klass) ⇒ Object


65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/capybara/screenshot/diff.rb', line 65

def self.included(klass)
  klass.include TestMethods
  klass.setup do
    if Capybara::Screenshot.window_size
      if page.driver.respond_to?(:resize)
        page.driver.resize(*Capybara::Screenshot.window_size)
      elsif selenium?
        page.driver.browser.manage.window.resize_to(*Capybara::Screenshot.window_size)
      end
    end
  end

  klass.teardown do
    if Capybara::Screenshot::Diff.enabled && @test_screenshots
      test_screenshot_errors = @test_screenshots
        .map { |caller, name, compare| assert_image_not_changed(caller, name, compare) }
      @test_screenshots = nil # release the comparison objects from memory
      test_screenshot_errors.compact!
      raise ASSERTION, test_screenshot_errors.join("\n\n") if test_screenshot_errors.any?
    end
  end
end