matches_selector? should allow all of the selectors filters

This commit is contained in:
Thomas Walpole 2016-09-23 09:56:07 -07:00
parent 09d350e49a
commit 109cfaba2e
4 changed files with 10 additions and 5 deletions

View File

@ -3,6 +3,7 @@ Release date: unreleased
### Fixed
* allow_label_click option did not work in some cases with Poltergeist - Issue #1762 [Thomas Walpole]
* matches_selector? should have access to all of a selectors filters [Thomas Walpole]
#Version 2.9.0
Release date: 2016-09-19

View File

@ -1,8 +1,6 @@
module Capybara
module Queries
class MatchQuery < Capybara::Queries::SelectorQuery
VALID_KEYS = [:text, :visible, :exact, :wait]
def visible
if options.has_key?(:visible)
super
@ -14,7 +12,7 @@ module Capybara
private
def valid_keys
VALID_KEYS + @selector.custom_filters.keys
super - COUNT_KEYS
end
end
end

View File

@ -42,6 +42,12 @@ Capybara::SpecHelper.spec '#match_selector?' do
expect(@element.matches_xpath?("//span", text: '42')).to be true
expect(@element.matches_xpath?("//span", text: 'Nope')).to be false
end
it 'should accept selector filters' do
@session.visit('/form')
cbox = @session.find(:css, '#form_pets_dog')
expect(cbox.matches_selector?(:checkbox, id: 'form_pets_dog', option: 'dog', name: 'form[pets][]', checked: true)).to be true
end
end
Capybara::SpecHelper.spec '#not_matches_selector?' do

View File

@ -96,7 +96,7 @@ RSpec.describe Capybara do
end
end
context "with :id option", twtw: true do
context "with :id option" do
it "works with compound css selectors" do
expect(string.all(:custom_css_selector, "div, h1", id: 'page').size).to eq 1
expect(string.all(:custom_css_selector, "h1, div", id: 'page').size).to eq 1
@ -109,7 +109,7 @@ RSpec.describe Capybara do
end
end
context "with :class option", twtw: true do
context "with :class option" do
it "works with compound css selectors" do
expect(string.all(:custom_css_selector, "div, h1", class: 'a').size).to eq 2
expect(string.all(:custom_css_selector, "h1, div", class: 'a').size).to eq 2