rspec-html 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +19 -15
- data/Makefile +1 -1
- data/lib/rspec/html/version.rb +1 -1
- data/lib/rspec_html/element.rb +1 -1
- data/lib/rspec_html/search.rb +7 -1
- data/rspec-documentation/pages/010-Usage/050-Enumerating Elements.md +21 -0
- 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: e46ebedf887629f4f11c117ca0e3183e2966abf9148120c675b980e34ea8eb3d
|
|
4
|
+
data.tar.gz: 1aefb7b84a37692de24edd83fd8cdb4127ceb0c385bb0d81526c425300f25c9c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a2e614b5b7064514d4dd27f2fe85b5e9940863abe0ebb3067af0c8f650f8da2245cb1829cea9eac8f1c992f23b1f72bb7b4111c646ef78ada24c7396ccccefbf
|
|
7
|
+
data.tar.gz: 78a0dea60b6260879e8f731cfa3b838c9523ef758b89ce998a5e82a86f86d52f7c65dbf9b2aa7bba6b488501504c33e5b37b48627a54e5f7c6f4da4c1c03421e
|
data/Gemfile
CHANGED
|
@@ -13,7 +13,7 @@ gem 'rake', '~> 13.0'
|
|
|
13
13
|
gem 'rspec-documentation', '~> 0.0.7'
|
|
14
14
|
gem 'rspec-file_fixtures', '~> 0.1.6'
|
|
15
15
|
gem 'rspec-its', '~> 1.3'
|
|
16
|
-
gem 'rubocop', '~> 1.
|
|
16
|
+
gem 'rubocop', '~> 1.64'
|
|
17
17
|
gem 'rubocop-rake', '~> 0.6.0'
|
|
18
18
|
gem 'rubocop-rspec', '~> 2.22'
|
|
19
19
|
gem 'strong_versions', '~> 0.4.5'
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rspec-html (0.3.
|
|
4
|
+
rspec-html (0.3.5)
|
|
5
5
|
nokogiri (~> 1.10)
|
|
6
6
|
rspec (~> 3.0)
|
|
7
7
|
|
|
@@ -22,11 +22,12 @@ GEM
|
|
|
22
22
|
htmlbeautifier (1.4.2)
|
|
23
23
|
i18n (1.14.1)
|
|
24
24
|
concurrent-ruby (~> 1.0)
|
|
25
|
-
json (2.
|
|
25
|
+
json (2.7.2)
|
|
26
26
|
kramdown (2.4.0)
|
|
27
27
|
rexml
|
|
28
28
|
kramdown-parser-gfm (1.1.0)
|
|
29
29
|
kramdown (~> 2.0)
|
|
30
|
+
language_server-protocol (3.17.0.3)
|
|
30
31
|
mail (2.8.1)
|
|
31
32
|
mini_mime (>= 0.1.1)
|
|
32
33
|
net-imap
|
|
@@ -47,16 +48,17 @@ GEM
|
|
|
47
48
|
racc (~> 1.4)
|
|
48
49
|
paint (2.3.0)
|
|
49
50
|
paintbrush (0.1.3)
|
|
50
|
-
parallel (1.
|
|
51
|
-
parser (3.
|
|
51
|
+
parallel (1.25.1)
|
|
52
|
+
parser (3.3.3.0)
|
|
52
53
|
ast (~> 2.4.1)
|
|
53
54
|
racc
|
|
54
|
-
racc (1.
|
|
55
|
+
racc (1.8.0)
|
|
55
56
|
rainbow (3.1.1)
|
|
56
57
|
rake (13.0.6)
|
|
57
58
|
redcarpet (3.6.0)
|
|
58
|
-
regexp_parser (2.
|
|
59
|
-
rexml (3.
|
|
59
|
+
regexp_parser (2.9.2)
|
|
60
|
+
rexml (3.3.1)
|
|
61
|
+
strscan
|
|
60
62
|
rouge (4.1.2)
|
|
61
63
|
rspec (3.12.0)
|
|
62
64
|
rspec-core (~> 3.12.0)
|
|
@@ -85,18 +87,19 @@ GEM
|
|
|
85
87
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
86
88
|
rspec-support (~> 3.12.0)
|
|
87
89
|
rspec-support (3.12.0)
|
|
88
|
-
rubocop (1.
|
|
90
|
+
rubocop (1.64.1)
|
|
89
91
|
json (~> 2.3)
|
|
92
|
+
language_server-protocol (>= 3.17.0)
|
|
90
93
|
parallel (~> 1.10)
|
|
91
|
-
parser (>= 3.
|
|
94
|
+
parser (>= 3.3.0.2)
|
|
92
95
|
rainbow (>= 2.2.2, < 4.0)
|
|
93
96
|
regexp_parser (>= 1.8, < 3.0)
|
|
94
97
|
rexml (>= 3.2.5, < 4.0)
|
|
95
|
-
rubocop-ast (>= 1.
|
|
98
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
96
99
|
ruby-progressbar (~> 1.7)
|
|
97
100
|
unicode-display_width (>= 2.4.0, < 3.0)
|
|
98
|
-
rubocop-ast (1.
|
|
99
|
-
parser (>= 3.
|
|
101
|
+
rubocop-ast (1.31.3)
|
|
102
|
+
parser (>= 3.3.1.0)
|
|
100
103
|
rubocop-capybara (2.18.0)
|
|
101
104
|
rubocop (~> 1.41)
|
|
102
105
|
rubocop-factory_bot (2.23.1)
|
|
@@ -111,10 +114,11 @@ GEM
|
|
|
111
114
|
strong_versions (0.4.5)
|
|
112
115
|
i18n (>= 0.5)
|
|
113
116
|
paint (~> 2.0)
|
|
117
|
+
strscan (3.1.0)
|
|
114
118
|
timeout (0.3.2)
|
|
115
119
|
tzinfo (2.0.6)
|
|
116
120
|
concurrent-ruby (~> 1.0)
|
|
117
|
-
unicode-display_width (2.
|
|
121
|
+
unicode-display_width (2.5.0)
|
|
118
122
|
zeitwerk (2.6.8)
|
|
119
123
|
|
|
120
124
|
PLATFORMS
|
|
@@ -130,10 +134,10 @@ DEPENDENCIES
|
|
|
130
134
|
rspec-file_fixtures (~> 0.1.6)
|
|
131
135
|
rspec-html!
|
|
132
136
|
rspec-its (~> 1.3)
|
|
133
|
-
rubocop (~> 1.
|
|
137
|
+
rubocop (~> 1.64)
|
|
134
138
|
rubocop-rake (~> 0.6.0)
|
|
135
139
|
rubocop-rspec (~> 2.22)
|
|
136
140
|
strong_versions (~> 0.4.5)
|
|
137
141
|
|
|
138
142
|
BUNDLED WITH
|
|
139
|
-
2.4.
|
|
143
|
+
2.4.22
|
data/Makefile
CHANGED
|
@@ -10,5 +10,5 @@ test:
|
|
|
10
10
|
.PHONY: publish
|
|
11
11
|
publish:
|
|
12
12
|
@RSPEC_DOCUMENTATION_URL_ROOT='/$(project)' bundle exec rspec-documentation
|
|
13
|
-
@rsync --delete -r rspec-documentation/bundle/
|
|
13
|
+
@rsync --delete -r rspec-documentation/bundle/ docs.bob.frl:/var/www/html/$(project)/
|
|
14
14
|
@echo 'Published.'
|
data/lib/rspec/html/version.rb
CHANGED
data/lib/rspec_html/element.rb
CHANGED
|
@@ -9,7 +9,7 @@ module RSpecHTML
|
|
|
9
9
|
|
|
10
10
|
def_delegators :@search,
|
|
11
11
|
:has_css?, :has_xpath?, :include?,
|
|
12
|
-
:all, :siblings, :text, :truncated_text, :attributes, :to_a,
|
|
12
|
+
:all, :siblings, :children, :text, :truncated_text, :attributes, :to_a,
|
|
13
13
|
:size, :length, :[],
|
|
14
14
|
:css, :xpath, :checked?,
|
|
15
15
|
:first, :last, :second, :third, :fourth, :fifth
|
data/lib/rspec_html/search.rb
CHANGED
|
@@ -83,7 +83,7 @@ module RSpecHTML
|
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
def attributes
|
|
86
|
-
@element&.attributes
|
|
86
|
+
@element&.attributes.to_h { |key, val| [key.to_sym, val.to_s] }
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
def size
|
|
@@ -93,6 +93,12 @@ module RSpecHTML
|
|
|
93
93
|
end
|
|
94
94
|
alias length size
|
|
95
95
|
|
|
96
|
+
def children(text: false) # rubocop:disable Metrics/CyclomaticComplexity
|
|
97
|
+
@element&.children
|
|
98
|
+
&.map { |child| Element.new(child, child.name, siblings: @element.children) }
|
|
99
|
+
&.reject { |child| text ? false : child.name == 'text' } || []
|
|
100
|
+
end
|
|
101
|
+
|
|
96
102
|
def new_from_find(tag, options)
|
|
97
103
|
Element.new(
|
|
98
104
|
find(tag),
|
|
@@ -14,6 +14,27 @@ it 'retrieves all matching elements' do
|
|
|
14
14
|
end
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
## `#children`
|
|
18
|
+
|
|
19
|
+
Use `#children` to access immediate child elements of the current element. Return an empty array if no children present.
|
|
20
|
+
|
|
21
|
+
```rspec:html
|
|
22
|
+
subject(:document) { parse_html('<div>text<span>span #1</span><span>span #2</span></div>') }
|
|
23
|
+
|
|
24
|
+
it 'retrieves all matching elements' do
|
|
25
|
+
expect(document.div.children.size).to eql 2
|
|
26
|
+
end
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Pass `text: true` to also include dangling text (default: `false`):
|
|
30
|
+
|
|
31
|
+
```rspec:html
|
|
32
|
+
subject(:document) { parse_html('<div>text<span>span #1</span><span>span #2</span></div>') }
|
|
33
|
+
|
|
34
|
+
it 'retrieves all matching elements' do
|
|
35
|
+
expect(document.div.children(text: true).size).to eql 3
|
|
36
|
+
end
|
|
37
|
+
```
|
|
17
38
|
## `#[]`
|
|
18
39
|
|
|
19
40
|
Use `#[]` to index a specific element from a matching set. Note that indexing starts at `1`, not `0`, so the first element in a set is `[1]`.
|
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.3.
|
|
4
|
+
version: 0.3.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bob Farrell
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-07-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|