Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Comparisons add ~50ms per image with VIPS. Without `ruby-vips`, ChunkyPNG is use

## Installation

**Requirements:** Ruby 3.2+. Rails 7.1+ for Rails integration; non-Rails projects supported via `CapybaraScreenshotDiff.serve()`. For the `:vips` driver: [libvips 8.9+](https://libvips.github.io/libvips/install.html).
**Requirements:** Ruby 3.2+. Rails 7.1+ for Rails integration; non-Rails projects supported via `CapybaraScreenshotDiff.serve()`. For the `:vips` driver: [libvips 8.9+](https://libvips.github.io/libvips/install.html). On macOS: `brew install vips`. On Ubuntu: `apt-get install libvips-dev`.

## Docs

Expand Down
10 changes: 10 additions & 0 deletions docs/framework-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,14 @@ Then('I should not see any visual difference') do
end
```

## Custom Test Frameworks

Minitest, RSpec, and Cucumber are supported out of the box. For other frameworks, call `finalize_reporters!` in your framework's "after suite" hook:

```ruby
CapybaraScreenshotDiff.finalize_reporters!
```

This generates the HTML report and prints the summary.

[← Back to README](../README.md)
10 changes: 3 additions & 7 deletions lib/capybara_screenshot_diff/reporters/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,9 @@ def write_report
end
end

# Auto-register reporter and at_exit hook.
# The reporter only writes when there are failures (finalize checks failures.empty?).
# Scripts that create their own reporter instance call record/finalize directly.
# Auto-register reporter.
# Framework adapters (Minitest, RSpec, Cucumber) call finalize_reporters! via native hooks.
# For custom frameworks, call CapybaraScreenshotDiff.finalize_reporters! manually.
unless CapybaraScreenshotDiff.reporters.any?(CapybaraScreenshotDiff::Reporters::HTML)
CapybaraScreenshotDiff.reporters << CapybaraScreenshotDiff::Reporters::HTML.new(embed_images: !!ENV["CI"])
end
Comment thread
sourcery-ai[bot] marked this conversation as resolved.

# Fallback for frameworks without explicit integration (e.g., Cucumber).
# Minitest and RSpec adapters call finalize_reporters! via their native hooks.
at_exit { CapybaraScreenshotDiff.finalize_reporters! }
Loading