Skip to content

Commit

Permalink
Delegate node equality to driver
Browse files Browse the repository at this point in the history
The native representation of a node may not be equal across driver
implementations.  Instead, let the driver define equality.
  • Loading branch information
mhoran committed Nov 20, 2012
1 parent 3aa63f1 commit 202e072
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions lib/capybara/driver/node.rb
Expand Up @@ -70,6 +70,10 @@ def inspect
rescue NotSupportedByDriverError
%(#<#{self.class} tag="#{tag_name}">)
end

def ==(other)
raise NotSupportedByDriverError
end
end
end
end
6 changes: 1 addition & 5 deletions lib/capybara/node/matchers.rb
Expand Up @@ -451,11 +451,7 @@ def has_no_table?(locator, options={})
end

def ==(other)
if other.respond_to?(:native)
self.eql?(other) or native == other.native
else
self.eql?(other)
end
self.eql?(other) or base == other.base
end

private
Expand Down
4 changes: 4 additions & 0 deletions lib/capybara/rack_test/node.rb
Expand Up @@ -97,6 +97,10 @@ def find(locator)
native.xpath(locator).map { |n| self.class.new(driver, n) }
end

def ==(other)
native == other.native
end

protected

def unnormalized_text
Expand Down
4 changes: 4 additions & 0 deletions lib/capybara/selenium/node.rb
Expand Up @@ -75,6 +75,10 @@ def find(locator)
native.find_elements(:xpath, locator).map { |n| self.class.new(driver, n) }
end

def ==(other)
native == other.native
end

private

# a reference to the select node if this is an option node
Expand Down

0 comments on commit 202e072

Please sign in to comment.