From 787405be40b550359902c8eec56ed14e419a4158 Mon Sep 17 00:00:00 2001 From: Jonas Nicklas Date: Sat, 10 Jul 2010 16:34:33 +0200 Subject: [PATCH] Explicit delegation instead of blanket forward --- lib/capybara/driver/node.rb | 6 ++++++ lib/capybara/node.rb | 29 ++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/lib/capybara/driver/node.rb b/lib/capybara/driver/node.rb index 744e3974..a46b3d1e 100644 --- a/lib/capybara/driver/node.rb +++ b/lib/capybara/driver/node.rb @@ -55,6 +55,12 @@ module Capybara def trigger(event) raise NotSupportedByDriverError end + + def inspect + %(#) + rescue NotSupportedByDriverError + %(#) + end end end end diff --git a/lib/capybara/node.rb b/lib/capybara/node.rb index f96d6b8b..79963b72 100644 --- a/lib/capybara/node.rb +++ b/lib/capybara/node.rb @@ -23,16 +23,35 @@ module Capybara end class Element < Node - # TODO: maybe we should explicitely delegate? - def method_missing(*args) - @base.send(*args) + extend Forwardable + + def_delegator :base, :text + def_delegator :base, :[] + def_delegator :base, :value + def_delegator :base, :set + def_delegator :base, :select_option + def_delegator :base, :unselect_option + def_delegator :base, :click + def_delegator :base, :tag_name + def_delegator :base, :visible? + def_delegator :base, :path + def_delegator :base, :trigger + + def drag_to(node) + base.drag_to(node.base) end - def respond_to?(method) - super || @base.respond_to?(method) + def inspect + %(#) + rescue NotSupportedByDriverError + %(#) end + end class Document < Node + def inspect + %(#) + end end end