From e1c9fb7c6c1c6f319b159dc4a83703a3b7cb97de Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Tue, 27 Nov 2012 14:32:28 +0900 Subject: [PATCH] == doesn't raise an exception for unrelated object --- lib/capybara/node/matchers.rb | 2 +- spec/rspec/matchers_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/capybara/node/matchers.rb b/lib/capybara/node/matchers.rb index 0cf61ec2..71ebd4b1 100644 --- a/lib/capybara/node/matchers.rb +++ b/lib/capybara/node/matchers.rb @@ -451,7 +451,7 @@ module Capybara end def ==(other) - self.eql?(other) or base == other.base + self.eql?(other) or (other.respond_to?(:base) and base == other.base) end private diff --git a/spec/rspec/matchers_spec.rb b/spec/rspec/matchers_spec.rb index ee4c996b..030eb8d4 100644 --- a/spec/rspec/matchers_spec.rb +++ b/spec/rspec/matchers_spec.rb @@ -573,4 +573,14 @@ describe Capybara::RSpecMatchers do end.to raise_error(/expected to find table "No such Table"/) end end + + describe "==" do + before do + visit('/with_html') + end + + it "returns false for unrelated object" do + page.find("html").should_not == "Not Capybara::Node::Base" + end + end end