Skip to content
Latest

Ruby test framework integration

RSpec with Capybara

require 'vizzly'
RSpec.describe 'Homepage', type: :feature do
it 'renders correctly' do
visit '/'
image_data = page.driver.browser.screenshot_as(:png)
Vizzly.screenshot('homepage', image_data,
properties: {
browser: Capybara.current_driver.to_s
}
)
end
end

Helper module

module VizzlyHelpers
def capture_screenshot(name, **options)
image_data = page.driver.browser.screenshot_as(:png)
Vizzly.screenshot(name, image_data, **options)
end
end

Forward the full options hash so callers can still set comparison options and request timeouts.

Minitest

image_data = page.driver.browser.screenshot_as(:png)
Vizzly.screenshot('dashboard', image_data)

Cucumber

When('I capture a screenshot named {string}') do |name|
image_data = page.driver.browser.screenshot_as(:png)
Vizzly.screenshot(name, image_data)
end

Good habits

  • Use stable screenshot names.
  • Add variant metadata in properties and configure those keys for baseline matching.
  • Run through vizzly run in CI when you want cloud results.

Next steps