rspec-html 0.2.16 → 0.2.17

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: 7f6a37320c65c9b804bc9e168b9b4db87c870fb41e65d8e87c01d63a706a4b22
4
- data.tar.gz: 27235c7b257a78227b616222bbced4d2478a422a243d07a09bfa35eaeec81385
3
+ metadata.gz: 202d1ada700f7071e92c4468a5a6777ce953c080d003ddb38da2b1368e0dc4fb
4
+ data.tar.gz: 16c180dc70119aa3152241e4dfd75249c563df2bf5091a08d594c54b14cf2baa
5
5
  SHA512:
6
- metadata.gz: 4aada61bea34ef005d8d7703ea22946f006040814413a7bf4a1983bd7f1a058dbde51db12b3a46437e7ba27db65fe478f345db03cc6f7e6c29d91af2ffebff8c
7
- data.tar.gz: 1bffb5835af37747cb144d82dae156f8e28b01af94312db10655f49208ee7e7ac6a9baede7656edd4c07ae667e0ba20c707cfa91c25dfcfb44716d5c52842017
6
+ metadata.gz: 0cc5a31d66fe3087d9248cb7528b088d667635672de83174f41b45b8a61d2708ade6f50db6cbcada675049bb30f684ed2df7cc83312b096cf4a0e5d1d1ed9dee
7
+ data.tar.gz: a6611b7dfd07963cbac2d5df0afd403e49afbc57419e5afdb9cc0a5604c73ad0de6407619d577fd03b98ab9675523596bc86aa7dfd89fa8667c58ed3acd95791
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-html (0.2.16)
4
+ rspec-html (0.2.17)
5
5
  nokogiri (~> 1.10)
6
6
  rspec (~> 3.0)
7
7
 
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module HTML
5
- VERSION = '0.2.16'
5
+ VERSION = '0.2.17'
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
- :siblings, :text, :truncated_text, :attributes,
12
+ :all, :siblings, :text, :truncated_text, :attributes,
13
13
  :size, :length, :[],
14
14
  :css, :xpath, :checked?
15
15
 
@@ -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.16
4
+ version: 0.2.17
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-01 00:00:00.000000000 Z
11
+ date: 2023-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri