Working on Webrat::Methods

This commit is contained in:
Bryan Helmkamp 2008-11-06 13:52:52 -05:00
parent 33e0000c5a
commit 5d3cb35370

View File

@ -11,31 +11,31 @@ module Webrat
end end
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 def webrat_session
@webrat_session ||= ::Webrat::Session.new @webrat_session ||= ::Webrat::Session.new
end end
delegate_to_session :within, :header, :http_accept, :basic_auth, delegate_to_session \
:save_and_open_page, :fill_in, :check, :visits, :visit,
:uncheck, :choose, :select, :attach_file, :within,
:field_labeled, :cookies, :response, :current_page, :header, :http_accept, :basic_auth,
:current_url :save_and_open_page,
:fill_in,
delegate_to_session_returning_response :visits, :click_link, :click_area, :click_button, :reload, :clicks_link_within :check,
:uncheck,
alias reloads reload :choose,
alias visit visits :select,
:attach_file,
:cookies,
:response,
:current_page,
:current_url,
:click_link,
:click_area,
:click_button,
:reload, :reloads,
:clicks_link_within,
:field_labeled
end end
end end