Module: CapybaraScreenshotDiff::Minitest::Assertions

Includes:
DSL
Defined in:
lib/capybara_screenshot_diff/minitest.rb

Instance Attribute Summary

Attributes included from Capybara::Screenshot::Diff::TestMethods

#test_screenshots

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Capybara::Screenshot::Diff::TestMethods

#assert_image_not_changed, #build_full_name, #group_parts, #initialize, #schedule_match_job, #screenshot_dir, #screenshot_group, #screenshot_section, #verify_screenshots!

Class Method Details

.included(klass) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/capybara_screenshot_diff/minitest.rb', line 30

def self.included(klass)
  klass.setup do
    if ::Capybara::Screenshot.window_size
      ::Capybara::Screenshot::BrowserHelpers.resize_to(::Capybara::Screenshot.window_size)
    end
  end

  klass.teardown do
    errors = verify_screenshots!(@test_screenshots)

    failures << ::Minitest::Assertion.new(errors.join("\n\n")) if errors && !errors.empty?
  end
end

Instance Method Details

#screenshotObject Also known as: assert_matches_screenshot



22
23
24
25
26
# File 'lib/capybara_screenshot_diff/minitest.rb', line 22

def screenshot(*, **)
  super
rescue CapybaraScreenshotDiff::ExpectationNotMet => e
  raise ::Minitest::Assertion, e.message
end