diff --git a/lib/capybara/node/matchers.rb b/lib/capybara/node/matchers.rb index b665a7251..b8e2492f3 100644 --- a/lib/capybara/node/matchers.rb +++ b/lib/capybara/node/matchers.rb @@ -416,6 +416,10 @@ def has_no_table?(locator, options={}) has_no_selector?(:table, locator, options) end + def ==(other) + native == other.native if other.respond_to?(:native) + end + private ## diff --git a/lib/capybara/spec/session/find_spec.rb b/lib/capybara/spec/session/find_spec.rb index f04c6c8bb..ec55163a0 100644 --- a/lib/capybara/spec/session/find_spec.rb +++ b/lib/capybara/spec/session/find_spec.rb @@ -13,6 +13,12 @@ @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'