diff --git a/README.md b/README.md index 8bc3e3ed..a0b01f79 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/framework-setup.md b/docs/framework-setup.md index 72160eb6..0716d169 100644 --- a/docs/framework-setup.md +++ b/docs/framework-setup.md @@ -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) diff --git a/lib/capybara_screenshot_diff/reporters/html.rb b/lib/capybara_screenshot_diff/reporters/html.rb index f3675849..c04490bd 100644 --- a/lib/capybara_screenshot_diff/reporters/html.rb +++ b/lib/capybara_screenshot_diff/reporters/html.rb @@ -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 - -# 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! }