Remove usage of method_missing in favor of explicit delegators
This commit is contained in:
parent
9979a29524
commit
9fd8a9ea82
@ -31,19 +31,6 @@ module Webrat
|
|||||||
def data
|
def data
|
||||||
@data
|
@data
|
||||||
end
|
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
|
def scope
|
||||||
@scope ||= Scope.new(self, session.response_body)
|
@scope ||= Scope.new(self, session.response_body)
|
||||||
@ -60,7 +47,5 @@ module Webrat
|
|||||||
@scope = nil
|
@scope = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,6 +1,8 @@
|
|||||||
module Webrat
|
module Webrat
|
||||||
class Session
|
class Session
|
||||||
|
extend Forwardable
|
||||||
|
include Logging
|
||||||
|
|
||||||
# Saves the page out to RAILS_ROOT/tmp/ and opens it in the default
|
# Saves the page out to RAILS_ROOT/tmp/ and opens it in the default
|
||||||
# web browser if on OS X. Useful for debugging.
|
# web browser if on OS X. Useful for debugging.
|
||||||
#
|
#
|
||||||
@ -88,10 +90,6 @@ module Webrat
|
|||||||
|
|
||||||
alias_method :visit, :visits
|
alias_method :visit, :visits
|
||||||
|
|
||||||
def respond_to?(name)
|
|
||||||
super || current_page.respond_to?(name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def open_in_browser(path) # :nodoc
|
def open_in_browser(path) # :nodoc
|
||||||
`open #{path}`
|
`open #{path}`
|
||||||
end
|
end
|
||||||
@ -100,14 +98,19 @@ module Webrat
|
|||||||
return response_html unless doc_root
|
return response_html unless doc_root
|
||||||
response_html.gsub(/"\/(stylesheets|images)/, doc_root + '/\1')
|
response_html.gsub(/"\/(stylesheets|images)/, doc_root + '/\1')
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_missing(name, *args, &block)
|
def_delegators :current_scope, :fill_in, :fills_in
|
||||||
if current_page.respond_to?(name)
|
def_delegators :current_scope, :check, :checks
|
||||||
current_scope.send(name, *args, &block)
|
def_delegators :current_scope, :uncheck, :unchecks
|
||||||
else
|
def_delegators :current_scope, :choose, :chooses
|
||||||
super
|
def_delegators :current_scope, :select, :selects
|
||||||
end
|
def_delegators :current_scope, :attach_file, :attaches_file
|
||||||
end
|
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
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user