From 6b007f41af9959e89887e42993615030c71cb5fa Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Fri, 18 Mar 2016 15:17:16 -0700 Subject: [PATCH] match_selector => matches_selector --- lib/capybara/node/matchers.rb | 22 +++++++++---------- lib/capybara/queries/match_query.rb | 2 +- lib/capybara/rspec/matchers.rb | 4 ++-- .../session/element/assert_match_selector.rb | 14 ++++++------ .../session/element/matches_selector_spec.rb | 10 ++++----- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/capybara/node/matchers.rb b/lib/capybara/node/matchers.rb index ec393144..42cbd91c 100644 --- a/lib/capybara/node/matchers.rb +++ b/lib/capybara/node/matchers.rb @@ -64,8 +64,8 @@ module Capybara # @param (see Capybara::Node::Finders#has_selector?) # @return [Boolean] # - def match_selector?(*args) - assert_match_selector(*args) + def matches_selector?(*args) + assert_matches_selector(*args) rescue Capybara::ExpectationNotMet return false end @@ -79,8 +79,8 @@ module Capybara # @param (see Capybara::Node::Finders#has_selector?) # @return [Boolean] # - def not_match_selector?(*args) - assert_not_match_selector(*args) + def not_matches_selector?(*args) + assert_not_matches_selector(*args) rescue Capybara::ExpectationNotMet return false end @@ -164,19 +164,19 @@ module Capybara # # Asserts that the current_node matches a given selector # - # node.assert_match_selector('p#foo') - # node.assert_match_selector(:xpath, '//p[@id="foo"]') - # node.assert_match_selector(:foo) + # node.assert_matches_selector('p#foo') + # node.assert_matches_selector(:xpath, '//p[@id="foo"]') + # node.assert_matches_selector(:foo) # # It also accepts all options that {Capybara::Node::Finders#all} accepts, # such as :text and :visible. # - # node.assert_match_selector('li', :text => 'Horse', :visible => true) + # node.assert_matches_selector('li', :text => 'Horse', :visible => true) # # @param (see Capybara::Node::Finders#all) # @raise [Capybara::ExpectationNotMet] If the selector does not match # - def assert_match_selector(*args) + def assert_matches_selector(*args) query = Capybara::Queries::MatchQuery.new(*args) synchronize(query.wait) do result = query.resolve_for(self.parent) @@ -187,7 +187,7 @@ module Capybara return true end - def assert_not_match_selector(*args) + def assert_not_matches_selector(*args) query = Capybara::Queries::MatchQuery.new(*args) synchronize(query.wait) do result = query.resolve_for(self.parent) @@ -197,7 +197,7 @@ module Capybara end return true end - alias_method :refute_match_selector, :assert_not_match_selector + alias_method :refute_matches_selector, :assert_not_matches_selector ## # diff --git a/lib/capybara/queries/match_query.rb b/lib/capybara/queries/match_query.rb index acd379a5..682ac920 100644 --- a/lib/capybara/queries/match_query.rb +++ b/lib/capybara/queries/match_query.rb @@ -14,7 +14,7 @@ module Capybara private def valid_keys - [:text, :visible, :exact, :wait] + @selector.custom_filters.keys + VALID_KEYS + @selector.custom_filters.keys end end end diff --git a/lib/capybara/rspec/matchers.rb b/lib/capybara/rspec/matchers.rb index 862a3540..422d21de 100644 --- a/lib/capybara/rspec/matchers.rb +++ b/lib/capybara/rspec/matchers.rb @@ -195,14 +195,14 @@ module Capybara end def matches?(actual) - actual.assert_match_selector(*@args) + actual.assert_matches_selector(*@args) rescue Capybara::ExpectationNotMet => e @failure_message = e.message return false end def does_not_match?(actual) - actual.assert_not_match_selector(*@args) + actual.assert_not_matches_selector(*@args) rescue Capybara::ExpectationNotMet => e @failure_message_when_negated = e.message return false diff --git a/lib/capybara/spec/session/element/assert_match_selector.rb b/lib/capybara/spec/session/element/assert_match_selector.rb index 48160db3..f52b8c7f 100644 --- a/lib/capybara/spec/session/element/assert_match_selector.rb +++ b/lib/capybara/spec/session/element/assert_match_selector.rb @@ -1,31 +1,31 @@ -Capybara::SpecHelper.spec '#assert_match_selector' do +Capybara::SpecHelper.spec '#assert_matches_selector' do before do @session.visit('/with_html') @element = @session.find(:css, 'span', text: '42') end it "should be true if the given selector matches the element" do - expect(@element.assert_match_selector(:css, '.number')).to be true + expect(@element.assert_matches_selector(:css, '.number')).to be true end it "should be false if the given selector does not match the element" do - expect { @element.assert_match_selector(:css, '.not_number') }.to raise_error(Capybara::ElementNotFound) + expect { @element.assert_matches_selector(:css, '.not_number') }.to raise_error(Capybara::ElementNotFound) end it "should not be callable on the session" do - expect { @session.assert_match_selector(:css, '.number') }.to raise_error(NoMethodError) + expect { @session.assert_matches_selector(:css, '.number') }.to raise_error(NoMethodError) end it "should wait for match to occur", requires: [:js] do @session.visit('/with_js') input = @session.find(:css, '#disable-on-click') - expect(input.assert_match_selector(:css, 'input:enabled')).to be true + expect(input.assert_matches_selector(:css, 'input:enabled')).to be true input.click - expect(input.assert_match_selector(:css, 'input:disabled')).to be true + expect(input.assert_matches_selector(:css, 'input:disabled')).to be true end it "should not accept count options" do - expect { @element.assert_match_selector(:css, '.number', count: 1) }.to raise_error(ArgumentError) + expect { @element.assert_matches_selector(:css, '.number', count: 1) }.to raise_error(ArgumentError) end end diff --git a/lib/capybara/spec/session/element/matches_selector_spec.rb b/lib/capybara/spec/session/element/matches_selector_spec.rb index 1b548569..9d394127 100644 --- a/lib/capybara/spec/session/element/matches_selector_spec.rb +++ b/lib/capybara/spec/session/element/matches_selector_spec.rb @@ -7,13 +7,13 @@ Capybara::SpecHelper.spec '#match_xpath?' do it "should be true if the element matches the given selector" do expect(@element).to match_selector(:xpath, "//span") expect(@element).to match_selector(:css, 'span.number') - expect(@element.match_selector?(:css, 'span.number')).to be true + expect(@element.matches_selector?(:css, 'span.number')).to be true end it "should be false if the element does not match the given selector" do expect(@element).not_to match_selector(:xpath, "//div") expect(@element).not_to match_selector(:css, "span.not_a_number") - expect(@element.match_selector?(:css, "span.not_a_number")).to be false + expect(@element.matches_selector?(:css, "span.not_a_number")).to be false end it "should use default selector" do @@ -30,7 +30,7 @@ Capybara::SpecHelper.spec '#match_xpath?' do end end -Capybara::SpecHelper.spec '#not_match_selector?' do +Capybara::SpecHelper.spec '#not_matches_selector?' do before do @session.visit('/with_html') @element = @session.find(:css, "span", text: 42) @@ -39,13 +39,13 @@ Capybara::SpecHelper.spec '#not_match_selector?' do it "should be false if the given selector matches the element" do expect(@element).not_to not_match_selector(:xpath, "//span") expect(@element).not_to not_match_selector(:css, "span.number") - expect(@element.not_match_selector?(:css, "span.number")).to be false + expect(@element.not_matches_selector?(:css, "span.number")).to be false end it "should be true if the given selector does not match the element" do expect(@element).to not_match_selector(:xpath, "//abbr") expect(@element).to not_match_selector(:css, "p a#doesnotexist") - expect(@element.not_match_selector?(:css, "p a#doesnotexist")).to be true + expect(@element.not_matches_selector?(:css, "p a#doesnotexist")).to be true end it "should use default selector" do