Sha256: 437f4cadf7ddc7136fc0f7af099b85da38f58744550b72ebb0eabec163a63afd

Contents?: true

Size: 600 Bytes

Versions: 1

Compression:

Stored size: 600 Bytes

Contents

require 'tempfile'
require 'capybara'

module Gnawrnip
  class Screenshot
    class << self

      #
      # Screenshot of current capybara session
      #
      # @example
      #   image = Gnawrnip::Screenshot.take
      #
      # @return  [String]  Base64-encoded image of screenshot
      #
      def take
        tempfile = Tempfile.new(['gnawrnip', '.png'])
        session.save_screenshot(tempfile.path)
        image = Base64.encode64(tempfile.read)
        tempfile.close
        image
      end

      private

      def session
        Capybara.current_session
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gnawrnip-0.0.4 lib/gnawrnip/screenshot.rb