rspec-html 0.2.10 → 0.2.11

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: d4bc7abc0e55d59ef4b3b1175dbca0022b5cdd0e2707f2d356ba46d5810feb2f
4
- data.tar.gz: 8a6a33977d7218bdba104a768fb7c601c88ad9aa0f6aaf157c8534e239813ea5
3
+ metadata.gz: 8052637b48c07f5312c3c0f6c4f3c42b790691758ab66b92240509bc19512b78
4
+ data.tar.gz: 28332c0112b53c97613bb24f387d6b9cef099527d363416856a44eab9e9f7260
5
5
  SHA512:
6
- metadata.gz: fe9b21c6c38c786e815f89f02e943263f60c88d772f532de0f9e50e4b3e017ea21bd264b9ecd464102d272f7c53c52ea12e70c279e8b2fbf0f5f9095cabfbde2
7
- data.tar.gz: 650e39fd4844ffacab77edadeb5a1229004b22a23bf38fe6e21f4d8c17e91c7f79dd22655184c209072e6ac5a7ed5ebe03e98d8854c83e8764b055ea2876dff1
6
+ metadata.gz: aa6583f785fd6e9da9e0a6c6d2a06e4f262e749e75d99e7a808fb937c3d08c882366424ffffcaf70e7d19de44027064435148ac9a8c9b3d4607ca67f218e5377
7
+ data.tar.gz: 419571c56771c6c5b46a7197ce3f8f3cb866c00e0db54201c1106e9f2105099c78461feb719b81ddf5d924b6098859f57e5c4107140583805ba84b3c6555a2d5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-html (0.2.9)
4
+ rspec-html (0.2.11)
5
5
  nokogiri (~> 1.10)
6
6
  rspec (~> 3.0)
7
7
 
data/README.md CHANGED
@@ -7,7 +7,7 @@ _RSpec::HTML_ provides a simple object interface to HTML responses from [_RSpec
7
7
  Add the gem to your `Gemfile`:
8
8
 
9
9
  ```ruby
10
- gem 'rspec-html', '~> 0.2.10'
10
+ gem 'rspec-html', '~> 0.2.11'
11
11
  ```
12
12
 
13
13
  And rebuild your bundle:
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module HTML
5
- VERSION = '0.2.10'
5
+ VERSION = '0.2.11'
6
6
  end
7
7
  end
@@ -8,7 +8,10 @@ module RSpecHTML
8
8
  extend Forwardable
9
9
 
10
10
  def_delegators :@search,
11
- :has_css?, :has_xpath?, :include?, :text, :truncated_text, :size, :length, :css, :xpath, :[]
11
+ :has_css?, :has_xpath?, :include?,
12
+ :siblings, :text, :truncated_text,
13
+ :size, :length, :[],
14
+ :css, :xpath
12
15
 
13
16
  def initialize(element, name, options: {}, siblings: [])
14
17
  @name = name
@@ -10,10 +10,28 @@ module RSpecHTML
10
10
 
11
11
  def match(actual)
12
12
  @rspec_actual = actual&.text
13
- return (actual&.text || '').include?(@expected.to_s) unless @expected.is_a?(Regexp)
13
+ return regexp_match?(actual) || regexp_siblings_match?(actual) if @expected.is_a?(Regexp)
14
14
 
15
+ string_match?(actual) || string_siblings_match?(actual)
16
+ end
17
+
18
+ private
19
+
20
+ def regexp_match?(actual)
15
21
  @expected.match(actual&.text || '')
16
22
  end
23
+
24
+ def regexp_siblings_match?(actual)
25
+ actual.siblings.any? { |sibling| @expected.match(sibling&.text || '') }
26
+ end
27
+
28
+ def string_match?(actual)
29
+ (actual&.text || '').include?(@expected.to_s)
30
+ end
31
+
32
+ def string_siblings_match?(actual)
33
+ actual.siblings.any? { |sibling| (sibling&.text || '').include?(@expected.to_s) }
34
+ end
17
35
  end
18
36
  end
19
37
  end
@@ -4,6 +4,8 @@ module RSpecHTML
4
4
  # Provides element/attribute/text searching for HTML entities
5
5
  # rubocop:disable Metrics/ClassLength
6
6
  class Search
7
+ attr_reader :siblings
8
+
7
9
  def initialize(element, siblings)
8
10
  @element = element
9
11
  @siblings = siblings
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.10
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-31 00:00:00.000000000 Z
11
+ date: 2022-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri