Sha256: a7ceeda89d36e87af5057af5c883878628cccbc0018ec1c3d300d1a6fff1bc63

Contents?: true

Size: 1.64 KB

Versions: 24

Compression:

Stored size: 1.64 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
      if Webrat.configuration.mode == :rack_test
        @_webrat_session ||= ::Webrat::RackTestSession.new(rack_test_session)
      else
        @_webrat_session ||= ::Webrat.session_class.new(self)
      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,
      :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

24 entries across 24 versions & 11 rubygems

Version Path
davidtrogers-webrat-0.4.4.2 lib/webrat/core/methods.rb
dbrady-webrat-0.4.4.2 lib/webrat/core/methods.rb
diabolo-webrat-0.4.4.2 lib/webrat/core/methods.rb
emipair-webrat-0.0.1 lib/webrat/core/methods.rb
garnierjm-webrat-0.4.5 lib/webrat/core/methods.rb
jwilger-webrat-0.4.4.3 lib/webrat/core/methods.rb
jwilger-webrat-0.4.4.4 lib/webrat/core/methods.rb
jwilger-webrat-0.4.4.5 lib/webrat/core/methods.rb
raldred-webrat-0.4.4.2 lib/webrat/core/methods.rb
sr-webrat-0.4.4.1 lib/webrat/core/methods.rb
honkster-webrat-0.4.4.2 lib/webrat/core/methods.rb
webrat-0.4.5 lib/webrat/core/methods.rb
metry-2.0.4 vendor/webrat/lib/webrat/core/methods.rb
metry-2.0.5 vendor/webrat/lib/webrat/core/methods.rb
metry-2.1.0 vendor/webrat/lib/webrat/core/methods.rb
metry-2.1.1 vendor/webrat/lib/webrat/core/methods.rb
metry-2.0.0 vendor/webrat/lib/webrat/core/methods.rb
metry-2.0.1 vendor/webrat/lib/webrat/core/methods.rb
metry-2.0.2 vendor/webrat/lib/webrat/core/methods.rb
metry-2.0.3 vendor/webrat/lib/webrat/core/methods.rb