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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c535d0ae9c4cf1a7f73cdae79bf0b09a6ad24e78fb7fe787ea098c9640456940
4
- data.tar.gz: 335afe827f7526ed40446930aa6555f06a54c76b0da532c0097b435e0d622ec0
3
+ metadata.gz: e46ebedf887629f4f11c117ca0e3183e2966abf9148120c675b980e34ea8eb3d
4
+ data.tar.gz: 1aefb7b84a37692de24edd83fd8cdb4127ceb0c385bb0d81526c425300f25c9c
5
5
  SHA512:
6
- metadata.gz: 161327678741ab16f3f010e8c4e3c30d9b098c63387d26e504f45cb54fd7115b2b21e6dd051a683312a489e6d007c3355e25ef3aed4a0f5451ec7fcdbff1d1e0
7
- data.tar.gz: b662a85ff8fb34ca580ec8a883bd5241201823cd64decb531929f478f03f24490aaaba123bdad005e2e51d2c52265581063229d19c5cc0c1b9bf35294dd8ce57
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.52'
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)
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.6.3)
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.23.0)
51
- parser (3.2.2.3)
51
+ parallel (1.25.1)
52
+ parser (3.3.3.0)
52
53
  ast (~> 2.4.1)
53
54
  racc
54
- racc (1.7.0)
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.8.1)
59
- rexml (3.2.5)
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.52.0)
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.2.0.0)
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.28.0, < 2.0)
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.29.0)
99
- parser (>= 3.2.1.0)
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.4.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.52)
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.13
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/ docs01.bob.frl:/mnt/docs/$(project)/
13
+ @rsync --delete -r rspec-documentation/bundle/ docs.bob.frl:/var/www/html/$(project)/
14
14
  @echo 'Published.'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module HTML
5
- VERSION = '0.3.4'
5
+ VERSION = '0.3.5'
6
6
  end
7
7
  end
@@ -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
@@ -83,7 +83,7 @@ module RSpecHTML
83
83
  end
84
84
 
85
85
  def attributes
86
- @element&.attributes&.to_h { |key, val| [key.to_sym, val.to_s] } || {}
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
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: 2023-06-11 00:00:00.000000000 Z
11
+ date: 2024-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri