Preserve notion of equality for nodes. closes #542

This commit is contained in:
Jonas Nicklas 2012-07-12 17:12:24 +02:00
parent ec56c52834
commit d791d5d7fd
2 changed files with 10 additions and 0 deletions

View File

@ -416,6 +416,10 @@ module Capybara
has_no_selector?(:table, locator, options)
end
def ==(other)
native == other.native if other.respond_to?(:native)
end
private
##

View File

@ -13,6 +13,12 @@ shared_examples_for "find" do
@session.find("//input[@id='test_field']")[:value].should == 'monkey'
end
it "preserve object identity", :focus => true do
(@session.find('//h1') == @session.find('//h1')).should be_true
(@session.find('//h1') === @session.find('//h1')).should be_true
(@session.find('//h1').eql? @session.find('//h1')).should be_false
end
it "should find the first element using the given locator and options" do
@session.find('//a', :text => 'Redirect')[:id].should == 'red'
@session.find(:css, 'a', :text => 'A link came first')[:title].should == 'twas a fine link'