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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f6a37320c65c9b804bc9e168b9b4db87c870fb41e65d8e87c01d63a706a4b22
4
- data.tar.gz: 27235c7b257a78227b616222bbced4d2478a422a243d07a09bfa35eaeec81385
3
+ metadata.gz: ed64650126b6d13ca7e26b3d221ac1c94f207fa07d861fcd32755a0066888a09
4
+ data.tar.gz: 19e69584d514d085b14f58990bc8e92ce6f037bea48ab8efd826e774633f1237
5
5
  SHA512:
6
- metadata.gz: 4aada61bea34ef005d8d7703ea22946f006040814413a7bf4a1983bd7f1a058dbde51db12b3a46437e7ba27db65fe478f345db03cc6f7e6c29d91af2ffebff8c
7
- data.tar.gz: 1bffb5835af37747cb144d82dae156f8e28b01af94312db10655f49208ee7e7ac6a9baede7656edd4c07ae667e0ba20c707cfa91c25dfcfb44716d5c52842017
6
+ metadata.gz: 7ab9654fe0b62ccd8f6ae7c34c6733f8251ef64e5c94d45ffc2b2edd93e0ed0a54ee1c0977a3c642e083eb2dfb9a18ca8259e9b796b5b169bf646cdf0dd2781d
7
+ data.tar.gz: 8689600fae2602785a021cb33385ff7ce8cc8972054f0946a2e9fab790b6d51e03c079a715a47543a752712749a4b1209fe0ccd666486d4efc6dc11ef7cde7aa
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.18)
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.18'
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
 
@@ -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.16
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-01 00:00:00.000000000 Z
11
+ date: 2023-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri