capybara 2.8.1 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yard/templates_custom/default/class/html/selectors.erb +38 -0
- data/.yard/templates_custom/default/class/html/setup.rb +17 -0
- data/.yard/yard_extensions.rb +78 -0
- data/.yardopts +1 -0
- data/History.md +13 -1
- data/README.md +1 -1
- data/lib/capybara/helpers.rb +0 -59
- data/lib/capybara/node/actions.rb +17 -11
- data/lib/capybara/node/finders.rb +9 -0
- data/lib/capybara/node/matchers.rb +54 -15
- data/lib/capybara/queries/base_query.rb +59 -3
- data/lib/capybara/queries/selector_query.rb +7 -16
- data/lib/capybara/queries/text_query.rb +11 -10
- data/lib/capybara/rack_test/form.rb +2 -1
- data/lib/capybara/result.rb +25 -10
- data/lib/capybara/rspec/features.rb +3 -2
- data/lib/capybara/rspec/matchers.rb +1 -1
- data/lib/capybara/selector.rb +277 -175
- data/lib/capybara/selector/filter_set.rb +3 -1
- data/lib/capybara/selector/selector.rb +227 -0
- data/lib/capybara/session.rb +2 -2
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +29 -1
- data/lib/capybara/spec/session/selectors_spec.rb +12 -0
- data/lib/capybara/spec/views/form.erb +11 -0
- data/lib/capybara/version.rb +1 -1
- data/spec/fixtures/capybara.csv +1 -0
- data/spec/fixtures/selenium_driver_rspec_failure.rb +1 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
- data/spec/rack_test_spec.rb +8 -0
- data/spec/result_spec.rb +3 -0
- data/spec/selenium_firefox_spec.rb +44 -0
- data/spec/selenium_spec_chrome.rb +5 -2
- data/spec/{selenium_spec.rb → shared_selenium_session.rb} +9 -43
- metadata +10 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 074717523be47e7a162c2d4bc45f5ff49737e6a8
|
4
|
+
data.tar.gz: 25c95e6c9273c09663933921ba177067e622ea65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1db39b289e31ac1432a30cbe5ff8ce957867e1b3fd854813d8bfa954af0babb5a89ac1ccfa21ff6d5074b112a69e4b6deb751bc9c054026bad65d9a2f7d6e0d
|
7
|
+
data.tar.gz: 635c3bfb9e2d366ad8bc87a2abe075f2286e496fd2171bf32e6ef6628a55f8f95dfee2fd8e326819ca81d1dc0c85ac0dfee86d0491c5710e5c53f6e756e50c65
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<div id="selectors">
|
2
|
+
<h2>Built-in Selectors</h2>
|
3
|
+
<ul>
|
4
|
+
<% @selectors.each do |name, selector| %>
|
5
|
+
<li>
|
6
|
+
<h3>:<%= name %></h3>
|
7
|
+
<div class="docstring">
|
8
|
+
<div class="discussion">
|
9
|
+
<p><%= h(selector.docstring) %></p>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
<div class="tags">
|
13
|
+
<p class="inline">Locator:</p>
|
14
|
+
<% if locator=selector.tag('locator') %>
|
15
|
+
<p class="inline"><%= h locator.text %></p>
|
16
|
+
<% end %>
|
17
|
+
<% if selector.has_tag?('filter') %>
|
18
|
+
<p>Filters:</p>
|
19
|
+
<ul class="param">
|
20
|
+
<% selector.tags('filter').each do |filter| %>
|
21
|
+
<li>
|
22
|
+
<span class="name"><%= filter.name %></span>
|
23
|
+
<% if filter.types %>
|
24
|
+
<span class="type">(<tt><%= h(filter.types.join(', ')) %></tt>)</span>
|
25
|
+
<% end %>
|
26
|
+
<% if filter.text %>
|
27
|
+
—
|
28
|
+
<div class="inline"><p><%= h filter.text %></p></div>
|
29
|
+
<% end %>
|
30
|
+
</li>
|
31
|
+
<% end %>
|
32
|
+
</ul>
|
33
|
+
<% end %>
|
34
|
+
</div
|
35
|
+
</li>
|
36
|
+
<% end %>
|
37
|
+
</ul>
|
38
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
def init
|
2
|
+
super
|
3
|
+
sections.place(:builtins).before(:subclasses)
|
4
|
+
end
|
5
|
+
|
6
|
+
def builtins
|
7
|
+
return if object.path != "Capybara::Selector" # only show built-in selectors for Selector class
|
8
|
+
|
9
|
+
@selectors = Registry.all(:selector)
|
10
|
+
return if @selectors.nil? || @selectors.empty?
|
11
|
+
|
12
|
+
@selectors = @selectors.map do |selector|
|
13
|
+
[selector.name, selector]
|
14
|
+
end
|
15
|
+
|
16
|
+
erb(:selectors)
|
17
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
YARD::Templates::Engine.register_template_path Pathname.new('./.yard/templates_custom')
|
2
|
+
|
3
|
+
YARD::Tags::Library.define_tag "Locator", :locator
|
4
|
+
YARD::Tags::Library.define_tag "Filter", :filter, :with_types_and_name
|
5
|
+
|
6
|
+
class SelectorObject < YARD::CodeObjects::Base
|
7
|
+
def path
|
8
|
+
"__Capybara" + sep + super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class AddSelectorHandler < YARD::Handlers::Ruby::Base
|
13
|
+
handles method_call(:add_selector)
|
14
|
+
namespace_only
|
15
|
+
process do
|
16
|
+
name = statement.parameters.first.jump(:tstring_content, :ident).source
|
17
|
+
# object = YARD::CodeObjects::MethodObject.new(namespace, name.to_sym)
|
18
|
+
# object = SelectorObject.new(YARD::Registry.resolve(P("Capybara"), "#add_selector", false, true), name.to_sym)
|
19
|
+
object = SelectorObject.new(namespace, name)
|
20
|
+
register(object)
|
21
|
+
parse_block(statement.last.last, :owner => object)
|
22
|
+
|
23
|
+
# modify the object
|
24
|
+
object.dynamic = true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class AddExpressionFilterHandler < YARD::Handlers::Ruby::Base
|
29
|
+
handles method_call(:xpath)
|
30
|
+
handles method_call(:css)
|
31
|
+
|
32
|
+
process do
|
33
|
+
return unless owner.is_a?(SelectorObject)
|
34
|
+
return if statement.parameters.empty?
|
35
|
+
# names = statement.parameters.children.map { |p| p.jump(:tstring_content, :ident).source.sub(/^:/, '') }
|
36
|
+
names = statement.parameters.children.map &:source
|
37
|
+
current_names = owner.tags(:filter).map(&:name)
|
38
|
+
(names-current_names).each do |name|
|
39
|
+
owner.add_tag(YARD::Tags::Tag.new(:filter, nil, nil, name))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class AddFilterHandler < YARD::Handlers::Ruby::Base
|
45
|
+
handles method_call(:filter)
|
46
|
+
|
47
|
+
process do
|
48
|
+
return unless owner.is_a?(SelectorObject)
|
49
|
+
return if statement.parameters.empty?
|
50
|
+
name = statement.parameters.first.source
|
51
|
+
type = if statement.parameters[1] && statement.parameters[1].source == ':boolean'
|
52
|
+
'Boolean'
|
53
|
+
else
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
if owner.tags(:filter).none? {|tag| tag.name == name }
|
57
|
+
filter_tag = YARD::Tags::Tag.new(:filter, nil, type, name)
|
58
|
+
owner.add_tag(filter_tag)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class FilterSetHandler < YARD::Handlers::Ruby::Base
|
64
|
+
handles method_call(:filter_set)
|
65
|
+
|
66
|
+
process do
|
67
|
+
return unless owner.is_a?(SelectorObject)
|
68
|
+
return if statement.parameters.empty? || !statement.parameters[1]
|
69
|
+
|
70
|
+
names = statement.parameters[1].flatten.map { |name| ":#{name}" }
|
71
|
+
names.each do |name|
|
72
|
+
if owner.tags(:filter).none? {|tag| tag.name == name }
|
73
|
+
filter_tag = YARD::Tags::Tag.new(:filter, nil, nil, name)
|
74
|
+
owner.add_tag(filter_tag)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--load ./.yard/yard_extensions.rb
|
data/History.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
|
+
#Version 2.9.0
|
2
|
+
Release date: 2016-09-19
|
3
|
+
|
4
|
+
### Fixed
|
5
|
+
* Issue with rack-test driver and obselete mime-types when using `#attach_file` - Issue #1756 [Thomas Walpole]
|
6
|
+
|
7
|
+
### Added
|
8
|
+
* `:class` option to many of the built-in selectors [Thomas Walpole]
|
9
|
+
* Removed need to specify value when creating `:boolean` filter type in custom selectors [Thomas Walpole]
|
10
|
+
* Filters can now be implemented through the XPath/CSS expressions in custom selectors [Thomas Walpole]
|
11
|
+
* `Element#matches_xpath?` and `Element#matches_css?` [Thomas Walpole]
|
12
|
+
|
1
13
|
#Version 2.8.1
|
2
|
-
Release
|
14
|
+
Release date: 2016-08-25
|
3
15
|
|
4
16
|
###Fixed
|
5
17
|
* Fixed error message from have_text when text is not found but contains regex special characters [Ryunosuke Sato]
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ through an external gem.
|
|
13
13
|
**Need help?** Ask on the mailing list (please do not open an issue on
|
14
14
|
GitHub): http://groups.google.com/group/ruby-capybara
|
15
15
|
|
16
|
-
**Note: Firefox 48** If you're using Firefox with selenium-
|
16
|
+
**Note: Firefox 48** If you're using Firefox with selenium-webdriver, stay on either Firefox [45.0esr](https://ftp.mozilla.org/pub/firefox/releases/45.0esr/) or [47.0.1](https://ftp.mozilla.org/pub/firefox/releases/47.0.1/) and selenium-webdriver 2.53.4. Firefox 48 requires geckodriver and selenium-webdriver v3, the combo of which currently has multiple issues and is feature incomplete.
|
17
17
|
|
18
18
|
## Table of contents
|
19
19
|
|
data/lib/capybara/helpers.rb
CHANGED
@@ -51,65 +51,6 @@ module Capybara
|
|
51
51
|
html
|
52
52
|
end
|
53
53
|
|
54
|
-
##
|
55
|
-
#
|
56
|
-
# Checks if the given count matches the given count options.
|
57
|
-
# Defaults to true if no options are specified. If multiple
|
58
|
-
# options are provided, it tests that all conditions are met;
|
59
|
-
# however, if :count is supplied, all other options are ignored.
|
60
|
-
#
|
61
|
-
# @param [Integer] count The actual number. Should be coercible via Integer()
|
62
|
-
# @option [Range] between Count must be within the given range
|
63
|
-
# @option [Integer] count Count must be exactly this
|
64
|
-
# @option [Integer] maximum Count must be smaller than or equal to this value
|
65
|
-
# @option [Integer] minimum Count must be larger than or equal to this value
|
66
|
-
#
|
67
|
-
def matches_count?(count, options={})
|
68
|
-
return (Integer(options[:count]) == count) if options[:count]
|
69
|
-
return false if options[:maximum] && (Integer(options[:maximum]) < count)
|
70
|
-
return false if options[:minimum] && (Integer(options[:minimum]) > count)
|
71
|
-
return false if options[:between] && !(options[:between] === count)
|
72
|
-
return true
|
73
|
-
end
|
74
|
-
|
75
|
-
##
|
76
|
-
#
|
77
|
-
# Checks if a count of 0 is valid for the given options hash.
|
78
|
-
# Returns false if options hash does not specify any count options.
|
79
|
-
#
|
80
|
-
def expects_none?(options={})
|
81
|
-
if [:count, :maximum, :minimum, :between].any? { |k| options.has_key? k }
|
82
|
-
matches_count?(0,options)
|
83
|
-
else
|
84
|
-
false
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
##
|
89
|
-
#
|
90
|
-
# Generates a failure message given a description of the query and count
|
91
|
-
# options.
|
92
|
-
#
|
93
|
-
# @param [String] description Description of a query
|
94
|
-
# @option [Range] between Count should have been within the given range
|
95
|
-
# @option [Integer] count Count should have been exactly this
|
96
|
-
# @option [Integer] maximum Count should have been smaller than or equal to this value
|
97
|
-
# @option [Integer] minimum Count should have been larger than or equal to this value
|
98
|
-
#
|
99
|
-
def failure_message(description, options={})
|
100
|
-
message = String.new("expected to find #{description}")
|
101
|
-
if options[:count]
|
102
|
-
message << " #{options[:count]} #{declension('time', 'times', options[:count])}"
|
103
|
-
elsif options[:between]
|
104
|
-
message << " between #{options[:between].first} and #{options[:between].last} times"
|
105
|
-
elsif options[:maximum]
|
106
|
-
message << " at most #{options[:maximum]} #{declension('time', 'times', options[:maximum])}"
|
107
|
-
elsif options[:minimum]
|
108
|
-
message << " at least #{options[:minimum]} #{declension('time', 'times', options[:minimum])}"
|
109
|
-
end
|
110
|
-
message
|
111
|
-
end
|
112
|
-
|
113
54
|
##
|
114
55
|
#
|
115
56
|
# A poor man's `pluralize`. Given two declensions, one singular and one
|
@@ -64,16 +64,18 @@ module Capybara
|
|
64
64
|
#
|
65
65
|
# page.fill_in 'Name', :with => 'Bob'
|
66
66
|
#
|
67
|
-
# @macro waiting_behavior
|
68
67
|
#
|
69
|
-
# @
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
68
|
+
# @overload fill_in([locator], options={})
|
69
|
+
# @param [String] locator Which field to fill in
|
70
|
+
# @param [Hash] options
|
71
|
+
# @macro waiting_behavior
|
72
|
+
# @option options [String] :with The value to fill in - required
|
73
|
+
# @option options [Hash] :fill_options Driver specific options regarding how to fill fields
|
74
|
+
# @option options [Boolean] :multiple Match fields that can have multiple values?
|
75
|
+
# @option options [String] :id Match fields that match the id attribute
|
76
|
+
# @option options [String] :name Match fields that match the name attribute
|
77
|
+
# @option options [String] :placeholder Match fields that match the placeholder attribute
|
78
|
+
# @option options [String, Array<String>] :class Match links that match the class(es) provided
|
77
79
|
#
|
78
80
|
def fill_in(locator, options={})
|
79
81
|
locator, options = nil, locator if locator.is_a? Hash
|
@@ -97,8 +99,9 @@ module Capybara
|
|
97
99
|
# @param [String] locator Which radio button to choose
|
98
100
|
#
|
99
101
|
# @option options [String] :option Value of the radio_button to choose
|
100
|
-
# @option options [String] id Match fields that match the id attribute
|
101
|
-
# @option options [String] name Match fields that match the name attribute
|
102
|
+
# @option options [String] :id Match fields that match the id attribute
|
103
|
+
# @option options [String] :name Match fields that match the name attribute
|
104
|
+
# @option options [String, Array<String>] :class Match links that match the class(es) provided
|
102
105
|
# @macro waiting_behavior
|
103
106
|
# @macro label_click
|
104
107
|
def choose(locator, options={})
|
@@ -133,6 +136,7 @@ module Capybara
|
|
133
136
|
# @option options [String] :option Value of the checkbox to select
|
134
137
|
# @option options [String] id Match fields that match the id attribute
|
135
138
|
# @option options [String] name Match fields that match the name attribute
|
139
|
+
# @option options [String, Array<String>] :class Match links that match the class(es) provided
|
136
140
|
# @macro label_click
|
137
141
|
# @macro waiting_behavior
|
138
142
|
#
|
@@ -168,6 +172,7 @@ module Capybara
|
|
168
172
|
# @option options [String] :option Value of the checkbox to deselect
|
169
173
|
# @option options [String] id Match fields that match the id attribute
|
170
174
|
# @option options [String] name Match fields that match the name attribute
|
175
|
+
# @option options [String, Array<String>] :class Match links that match the class(es) provided
|
171
176
|
# @macro label_click
|
172
177
|
# @macro waiting_behavior
|
173
178
|
#
|
@@ -253,6 +258,7 @@ module Capybara
|
|
253
258
|
# @option options [Boolean] multiple Match field which allows multiple file selection
|
254
259
|
# @option options [String] id Match fields that match the id attribute
|
255
260
|
# @option options [String] name Match fields that match the name attribute
|
261
|
+
# @option options [String, Array<String>] :class Match links that match the class(es) provided
|
256
262
|
#
|
257
263
|
def attach_file(locator, path, options={})
|
258
264
|
locator, path, options = nil, locator, path if path.is_a? Hash
|
@@ -70,6 +70,7 @@ module Capybara
|
|
70
70
|
# @option options [String] id Match fields that match the id attribute
|
71
71
|
# @option options [String] name Match fields that match the name attribute
|
72
72
|
# @option options [String] placeholder Match fields that match the placeholder attribute
|
73
|
+
# @option options [String, Array<String>] Match fields that match the class(es) passed
|
73
74
|
# @return [Capybara::Node::Element] The found element
|
74
75
|
#
|
75
76
|
|
@@ -89,6 +90,10 @@ module Capybara
|
|
89
90
|
# @macro waiting_behavior
|
90
91
|
#
|
91
92
|
# @option options [String,Regexp] href Value to match against the links href
|
93
|
+
# @option options [String] id Match links with the id provided
|
94
|
+
# @option options [String] title Match links with the title provided
|
95
|
+
# @option options [String] alt Match links with a contained img element whose alt matches
|
96
|
+
# @option options [String, Array<String>] class Match links that match the class(es) provided
|
92
97
|
# @return [Capybara::Node::Element] The found element
|
93
98
|
#
|
94
99
|
def find_link(locator=nil, options={})
|
@@ -114,6 +119,10 @@ module Capybara
|
|
114
119
|
# * true - only finds a disabled button
|
115
120
|
# * false - only finds an enabled button
|
116
121
|
# * :all - finds either an enabled or disabled button
|
122
|
+
# @option options [String] id Match buttons with the id provided
|
123
|
+
# @option options [String] title Match buttons with the title provided
|
124
|
+
# @option options [String] value Match buttons with the value provided
|
125
|
+
# @option options [String, Array<String>] class Match links that match the class(es) provided
|
117
126
|
# @return [Capybara::Node::Element] The found element
|
118
127
|
#
|
119
128
|
def find_button(locator=nil, options={})
|
@@ -5,7 +5,7 @@ module Capybara
|
|
5
5
|
|
6
6
|
##
|
7
7
|
#
|
8
|
-
# Checks if a given selector is on the page or current node.
|
8
|
+
# Checks if a given selector is on the page or a descendant of the current node.
|
9
9
|
#
|
10
10
|
# page.has_selector?('p#foo')
|
11
11
|
# page.has_selector?(:xpath, './/p[@id="foo"]')
|
@@ -44,7 +44,7 @@ module Capybara
|
|
44
44
|
|
45
45
|
##
|
46
46
|
#
|
47
|
-
# Checks if a given selector is not on the page or current node.
|
47
|
+
# Checks if a given selector is not on the page or a descendant of the current node.
|
48
48
|
# Usage is identical to Capybara::Node::Matchers#has_selector?
|
49
49
|
#
|
50
50
|
# @param (see Capybara::Node::Finders#has_selector?)
|
@@ -59,7 +59,6 @@ module Capybara
|
|
59
59
|
##
|
60
60
|
#
|
61
61
|
# Checks if the current node matches given selector
|
62
|
-
# Usage is identical to Capybara::Node::Matchers#has_selector?
|
63
62
|
#
|
64
63
|
# @param (see Capybara::Node::Finders#has_selector?)
|
65
64
|
# @return [Boolean]
|
@@ -70,6 +69,27 @@ module Capybara
|
|
70
69
|
return false
|
71
70
|
end
|
72
71
|
|
72
|
+
##
|
73
|
+
#
|
74
|
+
# Checks if the current node matches given XPath expression
|
75
|
+
#
|
76
|
+
# @param [String, XPath::Expression] xpath The XPath expression to match against the current code
|
77
|
+
# @return [Boolean]
|
78
|
+
#
|
79
|
+
def matches_xpath?(xpath, options={})
|
80
|
+
matches_selector?(:xpath, xpath, options)
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
#
|
85
|
+
# Checks if the current node matches given CSS selector
|
86
|
+
#
|
87
|
+
# @param [String] css The CSS selector to match against the current code
|
88
|
+
# @return [Boolean]
|
89
|
+
#
|
90
|
+
def matches_css?(css, options={})
|
91
|
+
matches_selector?(:css, css, options)
|
92
|
+
end
|
73
93
|
|
74
94
|
##
|
75
95
|
#
|
@@ -85,10 +105,31 @@ module Capybara
|
|
85
105
|
return false
|
86
106
|
end
|
87
107
|
|
108
|
+
##
|
109
|
+
#
|
110
|
+
# Checks if the current node does not match given XPath expression
|
111
|
+
#
|
112
|
+
# @param [String, XPath::Expression] xpath The XPath expression to match against the current code
|
113
|
+
# @return [Boolean]
|
114
|
+
#
|
115
|
+
def not_matches_xpath?(xpath, options={})
|
116
|
+
not_matches_selector?(:xpath, xpath, options)
|
117
|
+
end
|
118
|
+
|
119
|
+
##
|
120
|
+
#
|
121
|
+
# Checks if the current node does not match given CSS selector
|
122
|
+
#
|
123
|
+
# @param [String] css The CSS selector to match against the current code
|
124
|
+
# @return [Boolean]
|
125
|
+
#
|
126
|
+
def not_matches_css?(css, options={})
|
127
|
+
not_matches_selector?(:css, css, options)
|
128
|
+
end
|
88
129
|
|
89
130
|
##
|
90
131
|
#
|
91
|
-
# Asserts that a given selector is on the page or current node.
|
132
|
+
# Asserts that a given selector is on the page or a descendant of the current node.
|
92
133
|
#
|
93
134
|
# page.assert_selector('p#foo')
|
94
135
|
# page.assert_selector(:xpath, './/p[@id="foo"]')
|
@@ -123,7 +164,7 @@ module Capybara
|
|
123
164
|
query = Capybara::Queries::SelectorQuery.new(*args)
|
124
165
|
synchronize(query.wait) do
|
125
166
|
result = query.resolve_for(self)
|
126
|
-
unless result.matches_count? && ((!result.empty?) ||
|
167
|
+
unless result.matches_count? && ((!result.empty?) || query.expects_none?)
|
127
168
|
raise Capybara::ExpectationNotMet, result.failure_message
|
128
169
|
end
|
129
170
|
end
|
@@ -132,7 +173,7 @@ module Capybara
|
|
132
173
|
|
133
174
|
##
|
134
175
|
#
|
135
|
-
# Asserts that a given selector is not on the page or current node.
|
176
|
+
# Asserts that a given selector is not on the page or a descendant of the current node.
|
136
177
|
# Usage is identical to Capybara::Node::Matchers#assert_selector
|
137
178
|
#
|
138
179
|
# Query options such as :count, :minimum, :maximum, and :between are
|
@@ -150,7 +191,7 @@ module Capybara
|
|
150
191
|
query = Capybara::Queries::SelectorQuery.new(*args)
|
151
192
|
synchronize(query.wait) do
|
152
193
|
result = query.resolve_for(self)
|
153
|
-
if result.matches_count? && ((!result.empty?) ||
|
194
|
+
if result.matches_count? && ((!result.empty?) || query.expects_none?)
|
154
195
|
raise Capybara::ExpectationNotMet, result.negative_failure_message
|
155
196
|
end
|
156
197
|
end
|
@@ -199,7 +240,7 @@ module Capybara
|
|
199
240
|
|
200
241
|
##
|
201
242
|
#
|
202
|
-
# Checks if a given XPath expression is on the page or current node.
|
243
|
+
# Checks if a given XPath expression is on the page or a descendant of the current node.
|
203
244
|
#
|
204
245
|
# page.has_xpath?('.//p[@id="foo"]')
|
205
246
|
#
|
@@ -232,7 +273,7 @@ module Capybara
|
|
232
273
|
|
233
274
|
##
|
234
275
|
#
|
235
|
-
# Checks if a given XPath expression is not on the page or current node.
|
276
|
+
# Checks if a given XPath expression is not on the page or a descendant of the current node.
|
236
277
|
# Usage is identical to Capybara::Node::Matchers#has_xpath?
|
237
278
|
#
|
238
279
|
# @param (see Capybara::Node::Finders#has_xpath?)
|
@@ -244,7 +285,7 @@ module Capybara
|
|
244
285
|
|
245
286
|
##
|
246
287
|
#
|
247
|
-
# Checks if a given CSS selector is on the page or current node.
|
288
|
+
# Checks if a given CSS selector is on the page or a descendant of the current node.
|
248
289
|
#
|
249
290
|
# page.has_css?('p#foo')
|
250
291
|
#
|
@@ -271,7 +312,7 @@ module Capybara
|
|
271
312
|
|
272
313
|
##
|
273
314
|
#
|
274
|
-
# Checks if a given CSS selector is not on the page or current node.
|
315
|
+
# Checks if a given CSS selector is not on the page or a descendant of the current node.
|
275
316
|
# Usage is identical to Capybara::Node::Matchers#has_css?
|
276
317
|
#
|
277
318
|
# @param (see Capybara::Node::Finders#has_css?)
|
@@ -520,8 +561,7 @@ module Capybara
|
|
520
561
|
query = Capybara::Queries::TextQuery.new(*args)
|
521
562
|
synchronize(query.wait) do
|
522
563
|
count = query.resolve_for(self)
|
523
|
-
|
524
|
-
unless matches_count && ((count > 0) || Capybara::Helpers.expects_none?(query.options))
|
564
|
+
unless query.matches_count?(count) && ((count > 0) || query.expects_none?)
|
525
565
|
raise Capybara::ExpectationNotMet, query.failure_message
|
526
566
|
end
|
527
567
|
end
|
@@ -540,8 +580,7 @@ module Capybara
|
|
540
580
|
query = Capybara::Queries::TextQuery.new(*args)
|
541
581
|
synchronize(query.wait) do
|
542
582
|
count = query.resolve_for(self)
|
543
|
-
|
544
|
-
if matches_count && ((count > 0) || Capybara::Helpers.expects_none?(query.options))
|
583
|
+
if query.matches_count?(count) && ((count > 0) || query.expects_none?)
|
545
584
|
raise Capybara::ExpectationNotMet, query.negative_failure_message
|
546
585
|
end
|
547
586
|
end
|