Remove usage of method_missing in favor of explicit delegators

This commit is contained in:
Bryan Helmkamp 2008-08-10 15:08:52 -04:00
parent 9979a29524
commit 9fd8a9ea82
2 changed files with 16 additions and 28 deletions

View File

@ -32,19 +32,6 @@ module Webrat
@data
end
def_delegators :scope, :fill_in, :fills_in
def_delegators :scope, :check, :checks
def_delegators :scope, :uncheck, :unchecks
def_delegators :scope, :choose, :chooses
def_delegators :scope, :select, :selects
def_delegators :scope, :attach_file, :attaches_file
def_delegators :scope, :click_link, :clicks_link
def_delegators :scope, :click_get_link, :clicks_get_link
def_delegators :scope, :click_delete_link, :clicks_delete_link
def_delegators :scope, :click_post_link, :clicks_post_link
def_delegators :scope, :click_put_link, :clicks_put_link
def_delegators :scope, :click_button, :clicks_button
def scope
@scope ||= Scope.new(self, session.response_body)
end
@ -60,7 +47,5 @@ module Webrat
@scope = nil
end
end
end

View File

@ -1,5 +1,7 @@
module Webrat
class Session
extend Forwardable
include Logging
# Saves the page out to RAILS_ROOT/tmp/ and opens it in the default
# web browser if on OS X. Useful for debugging.
@ -88,10 +90,6 @@ module Webrat
alias_method :visit, :visits
def respond_to?(name)
super || current_page.respond_to?(name)
end
def open_in_browser(path) # :nodoc
`open #{path}`
end
@ -101,13 +99,18 @@ module Webrat
response_html.gsub(/"\/(stylesheets|images)/, doc_root + '/\1')
end
def method_missing(name, *args, &block)
if current_page.respond_to?(name)
current_scope.send(name, *args, &block)
else
super
end
end
def_delegators :current_scope, :fill_in, :fills_in
def_delegators :current_scope, :check, :checks
def_delegators :current_scope, :uncheck, :unchecks
def_delegators :current_scope, :choose, :chooses
def_delegators :current_scope, :select, :selects
def_delegators :current_scope, :attach_file, :attaches_file
def_delegators :current_scope, :click_link, :clicks_link
def_delegators :current_scope, :click_get_link, :clicks_get_link
def_delegators :current_scope, :click_delete_link, :clicks_delete_link
def_delegators :current_scope, :click_post_link, :clicks_post_link
def_delegators :current_scope, :click_put_link, :clicks_put_link
def_delegators :current_scope, :click_button, :clicks_button
end
end