Sha256: 6131f0951000cd12a1add6b9824be3845ce2f59490157b1f8b2d736d7706ec64

Contents?: true

Size: 1.65 KB

Versions: 16

Compression:

Stored size: 1.65 KB

Contents

module Webrat
  module Methods #:nodoc:

    def self.delegate_to_session(*meths)
      meths.each do |meth|
        self.class_eval <<-RUBY
          def #{meth}(*args, &blk)
            webrat_session.#{meth}(*args, &blk)
          end
        RUBY
      end
    end

    def webrat
      webrat_session
    end

    def webrat_session
      @_webrat_session ||= begin
        session = Webrat.session_class.new
        session.adapter = Webrat.adapter_class.new(self) if session.respond_to?(:adapter=)
        session
      end
    end

    # all of these methods delegate to the @session, which should
    # be created transparently.
    #
    # Note that when using Webrat, #request also uses @session, so
    # that #request and webrat native functions behave interchangably

    delegate_to_session \
      :visits, :visit,
      :within,
      :header, :http_accept, :basic_auth,
      :save_and_open_page,
      :fills_in, :fill_in,
      :checks, :check,
      :unchecks, :uncheck,
      :chooses, :choose,
      :selects, :select,
      :unselects, :unselect,
      :attaches_file, :attach_file,
      :current_page,
      :current_url,
      :clicks_link, :click_link,
      :clicks_area, :click_area,
      :clicks_button, :click_button,
      :reload, :reloads,
      :clicks_link_within, :click_link_within,
      :field_labeled,
      :select_option,
      :set_hidden_field, :submit_form,
      :request_page, :current_dom,
      :response_body,
      :selects_date, :selects_time, :selects_datetime,
      :select_date, :select_time, :select_datetime,
      :field_by_xpath,
      :field_with_id,
      :selenium,
      :simulate, :automate,
      :field_named
  end
end

Version data entries

16 entries across 16 versions & 9 rubygems

Version Path
revo-webrat-0.7.0.1 lib/webrat/core/methods.rb
davidtrogers-webrat-0.7.0 lib/webrat/core/methods.rb
revo-webrat-0.7.0 lib/webrat/core/methods.rb
revo-webrat-0.7.1.pre lib/webrat/core/methods.rb
webrat-0.7.0 lib/webrat/core/methods.rb
honkster-webrat-0.6.0.10 lib/webrat/core/methods.rb
honkster-webrat-0.6.0.9 lib/webrat/core/methods.rb
darkofabijan-webrat-0.6.1 lib/webrat/core/methods.rb
kbaum-webrat-0.5.1 lib/webrat/core/methods.rb
kbaum-webrat-0.6.1.pre lib/webrat/core/methods.rb
cynergy-webrat-0.6.0 lib/webrat/core/methods.rb
webrat-0.6.0 lib/webrat/core/methods.rb
radar-webrat-0.5.1.1 lib/webrat/core/methods.rb
radar-webrat-0.5.1 lib/webrat/core/methods.rb
mkuklis-webrat-0.5.1 lib/webrat/core/methods.rb
honkster-webrat-0.6.0 lib/webrat/core/methods.rb