Skip to content

Commit

Permalink
Preserve notion of equality for nodes. closes #542
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed Jul 12, 2012
1 parent ec56c52 commit d791d5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/capybara/node/matchers.rb
Expand Up @@ -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

##
Expand Down
6 changes: 6 additions & 0 deletions lib/capybara/spec/session/find_spec.rb
Expand Up @@ -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'
Expand Down

0 comments on commit d791d5d

Please sign in to comment.