Sha256: 07e0d76dac44e074f873a2bdb7dbd1c0e39df13325ee0ad772b348dfe91d3369

Contents?: true

Size: 677 Bytes

Versions: 2

Compression:

Stored size: 677 Bytes

Contents

require "capybara"
require "capybara/screenshot_config/version"
require "capybara/screenshot_config/configuration"

module Capybara
  module ScreenshotConfig
    class << self
      def configure
        yield(configuration)
      end

      def configuration
        @configuration ||= Configuration.new
      end
    end
  end

  # monkey patching Capybara::Session#save_screenshot
  class Session
    alias_method :old_save_screenshot, :save_screenshot

    def save_screenshot(path, options={})
      options = ScreenshotConfig.configuration.options.merge(options)

      old_save_screenshot("#{ScreenshotConfig.configuration.save_dir}/#{path}", options)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capybara-screenshot_config-0.1.0 lib/capybara/screenshot_config.rb
capybara-screenshot_config-0.0.1 lib/capybara/screenshot_config.rb