Sha256: 37478adce308d9f2602de6dc9e07006f0645d73556fae18f097510accbf185e8

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

require 'capybara/flow/empty_recorder'

module Capybara
  module Flow
    VERSION = File.read(File.join(File.dirname(__FILE__), "..", "..", "VERSION")).freeze

    class << self
      attr_writer :configuration
    end

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

    def self.configure
      yield(configuration)
    end

    def self.included(base)
      base.send(:prepend, UserActions)
    end

    def recorder
      @recorder ||= EmptyRecorder.new
    end

    def recorder=(other)
      @recorder = other
    end

    MATCHERS = [
      :have_content
    ]

    USER_ACTIONS = [
      :attach_file,
      :check,
      :uncheck,
      :choose,
      :click_button,
      :click_link,
      :click_link_or_button,
      :click_on,
      # :evaluate_script, #BAD FOR PERCY
      :execute_script,
      :fill_in,
      :go_back,
      :go_forward,
      :select,
      :unselect,
      :visit
    ].freeze

    module UserActions
      USER_ACTIONS.each do |action_method|
        define_method action_method do |*args, &block|
          super(*args, &block)
          self.recorder.add(self)
        end
      end

      MATCHERS.each do |matcher_method|
        define_method matcher_method do |arg|
          self.recorder.add(self)
          super(arg)
        end
      end
    end
  end
end

require 'capybara/flow/gif_animator'
require 'capybara/flow/gif_recorder'
require 'capybara/flow/configuration'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capybara-flow-0.2.2 lib/capybara/flow.rb