Skip to content

Commit

Permalink
Working on Webrat::Methods
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Nov 6, 2008
1 parent 33e0000 commit 5d3cb35
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions lib/webrat/core/methods.rb
Expand Up @@ -11,31 +11,31 @@ def #{meth}(*args, &blk)
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

0 comments on commit 5d3cb35

Please sign in to comment.