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/image_compare.rb,
lib/capybara/screenshot/diff/stabilization.rb

Overview

Module to track screen shot changes

Defined Under Namespace

Modules: Stabilization, TestMethods, Vcs Classes: ImageCompare

Constant Summary collapse

VERSION =
'1.0.0'

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(clas) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/capybara/screenshot/diff.rb', line 48

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

  clas.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) }.compact!
      fail(test_screenshot_errors.join("\n\n")) if test_screenshot_errors.any?
    end
  end
end