Class: CapybaraScreenshotDiff::AssertionRegistry
- Inherits:
-
Object
- Object
- CapybaraScreenshotDiff::AssertionRegistry
- Defined in:
- lib/capybara_screenshot_diff/screenshot_assertion.rb
Instance Attribute Summary collapse
-
#assertions ⇒ Object
readonly
Returns the value of attribute assertions.
Instance Method Summary collapse
- #add_assertion(assertion) ⇒ Object
- #assertions_present? ⇒ Boolean
- #failed_assertions ⇒ Object
-
#initialize ⇒ AssertionRegistry
constructor
A new instance of AssertionRegistry.
- #reset ⇒ Object
- #verify(screenshots = CapybaraScreenshotDiff.assertions) ⇒ Object
Constructor Details
#initialize ⇒ AssertionRegistry
Returns a new instance of AssertionRegistry.
78 79 80 |
# File 'lib/capybara_screenshot_diff/screenshot_assertion.rb', line 78 def initialize @assertions = [] end |
Instance Attribute Details
#assertions ⇒ Object (readonly)
Returns the value of attribute assertions.
76 77 78 |
# File 'lib/capybara_screenshot_diff/screenshot_assertion.rb', line 76 def assertions @assertions end |
Instance Method Details
#add_assertion(assertion) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/capybara_screenshot_diff/screenshot_assertion.rb', line 82 def add_assertion(assertion) assertion = ScreenshotAssertion.from(assertion) return unless assertion.compare @assertions.push(assertion) assertion end |
#assertions_present? ⇒ Boolean
91 92 93 |
# File 'lib/capybara_screenshot_diff/screenshot_assertion.rb', line 91 def assertions_present? !@assertions.empty? end |
#failed_assertions ⇒ Object
101 102 103 |
# File 'lib/capybara_screenshot_diff/screenshot_assertion.rb', line 101 def failed_assertions assertions.filter { |screenshot_assert| screenshot_assert.compare&.different? } end |
#reset ⇒ Object
105 106 107 |
# File 'lib/capybara_screenshot_diff/screenshot_assertion.rb', line 105 def reset @assertions.clear end |
#verify(screenshots = CapybaraScreenshotDiff.assertions) ⇒ Object
95 96 97 98 99 |
# File 'lib/capybara_screenshot_diff/screenshot_assertion.rb', line 95 def verify(screenshots = CapybaraScreenshotDiff.assertions) result = ScreenshotAssertion.verify_screenshots!(screenshots) raise CapybaraScreenshotDiff::ExpectationNotMet, result.join("\n\n") if result end |