Sha256: 5ccf3451b436fcec88d91c1bf4f19ec0dd746803e66802d9febb2ddb45c99c84

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 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 ||= ::Webrat::MerbSession.new
            @_webrat_session.#{meth}(*args, &blk)
          end
        RUBY
      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,
      :fill_in,
      :check, 
      :uncheck,
      :choose,
      :select,
      :attach_file,
      :cookies,
      :response,
      :current_page,
      :current_url,
      :click_link,
      :click_area,
      :click_button,
      :reload, :reloads,
      :clicks_link_within,
      :field_labeled
    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
webrat-0.3.3 lib/webrat/core/methods.rb
webrat-0.3.1 lib/webrat/core/methods.rb
webrat-0.3.2 lib/webrat/core/methods.rb
webrat-0.3.4 lib/webrat/core/methods.rb