Working on Webrat::Methods

This commit is contained in:
Bryan Helmkamp 2008-11-06 13:52:52 -05:00
parent 33e0000c5a
commit 5d3cb35370
1 changed files with 21 additions and 21 deletions

View File

@ -11,31 +11,31 @@ module Webrat
end
end
def self.delegate_to_session_returning_response(*meths)
meths.each do |meth|
self.class_eval <<-RUBY
def #{meth}(*args, &blk)
webrat_session.#{meth}(*args, &blk)
return webrat_session.response
end
RUBY
end
end
def webrat_session
@webrat_session ||= ::Webrat::Session.new
end
delegate_to_session :within, :header, :http_accept, :basic_auth,
:save_and_open_page, :fill_in, :check,
:uncheck, :choose, :select, :attach_file,
:field_labeled, :cookies, :response, :current_page,
:current_url
delegate_to_session_returning_response :visits, :click_link, :click_area, :click_button, :reload, :clicks_link_within
alias reloads reload
alias visit visits
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