rspec-html 0.2.16 → 0.2.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/lib/rspec/html/version.rb +1 -1
- data/lib/rspec_html/element.rb +1 -1
- data/lib/rspec_html/search.rb +8 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed64650126b6d13ca7e26b3d221ac1c94f207fa07d861fcd32755a0066888a09
|
4
|
+
data.tar.gz: 19e69584d514d085b14f58990bc8e92ce6f037bea48ab8efd826e774633f1237
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ab9654fe0b62ccd8f6ae7c34c6733f8251ef64e5c94d45ffc2b2edd93e0ed0a54ee1c0977a3c642e083eb2dfb9a18ca8259e9b796b5b169bf646cdf0dd2781d
|
7
|
+
data.tar.gz: 8689600fae2602785a021cb33385ff7ce8cc8972054f0946a2e9fab790b6d51e03c079a715a47543a752712749a4b1209fe0ccd666486d4efc6dc11ef7cde7aa
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -97,6 +97,12 @@ expect(document.body.div.span[:class]).to contain_text 'my-class'
|
|
97
97
|
expect(document.body.div.span['data-content']).to contain_text 'my content'
|
98
98
|
```
|
99
99
|
|
100
|
+
#### Retrieve all matching elements
|
101
|
+
To select all matching elements as an array, use `#all`:
|
102
|
+
```ruby
|
103
|
+
expect(document.span.all.map(&:text)).to eql ['foo', 'bar', 'baz']
|
104
|
+
```
|
105
|
+
|
100
106
|
#### Indexing a Matching Set
|
101
107
|
To select an index from a set of matched elements use the array-style interface (the first matching element is `1`, not `0`):
|
102
108
|
```ruby
|
data/lib/rspec/html/version.rb
CHANGED
data/lib/rspec_html/element.rb
CHANGED
data/lib/rspec_html/search.rb
CHANGED
@@ -21,11 +21,11 @@ module RSpecHTML
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def css(*args)
|
24
|
-
self.class.new(@element&.css(*args), :css)
|
24
|
+
self.class.new(@element&.css(*args), :css, element_wrapper)
|
25
25
|
end
|
26
26
|
|
27
27
|
def xpath(*args)
|
28
|
-
self.class.new(@element&.xpath(*args), :xpath)
|
28
|
+
self.class.new(@element&.xpath(*args), :xpath, element_wrapper)
|
29
29
|
end
|
30
30
|
|
31
31
|
def present?
|
@@ -39,6 +39,12 @@ module RSpecHTML
|
|
39
39
|
@element.attributes.key?('checked')
|
40
40
|
end
|
41
41
|
|
42
|
+
def all
|
43
|
+
return [] if @siblings.nil?
|
44
|
+
|
45
|
+
@siblings.map { |sibling| Element.new(sibling, @element&.name) }
|
46
|
+
end
|
47
|
+
|
42
48
|
# rubocop:disable Naming/PredicateName
|
43
49
|
def has_css?(*args)
|
44
50
|
!@element&.css(*args)&.empty?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|