rspec-html 0.2.18 → 0.2.20

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: ed64650126b6d13ca7e26b3d221ac1c94f207fa07d861fcd32755a0066888a09
4
- data.tar.gz: 19e69584d514d085b14f58990bc8e92ce6f037bea48ab8efd826e774633f1237
3
+ metadata.gz: aaee41aa5d576b503c3e8ae1c8e99c144f5536d7975c724786ddd8331f41381f
4
+ data.tar.gz: 15d291a353ca7f423144ca71cdc987462549635e53a282a7380545a61c04e829
5
5
  SHA512:
6
- metadata.gz: 7ab9654fe0b62ccd8f6ae7c34c6733f8251ef64e5c94d45ffc2b2edd93e0ed0a54ee1c0977a3c642e083eb2dfb9a18ca8259e9b796b5b169bf646cdf0dd2781d
7
- data.tar.gz: 8689600fae2602785a021cb33385ff7ce8cc8972054f0946a2e9fab790b6d51e03c079a715a47543a752712749a4b1209fe0ccd666486d4efc6dc11ef7cde7aa
6
+ metadata.gz: b29060e93d1eb05b1a199832c3ac4e62ad7ad60d9357d779a25da407e0e700fd718ad6c102888117695ed942a0669391371006908cc44b818e82fdff76d23bdc
7
+ data.tar.gz: a71db0d5b3c2e34e33716e38c86579f7b180d8b0cea013a3945d1bb5e9fa1319b90d6b230c66f4c7ed0d051e7fd4acc9ff45c05ace702ae1c6a408de913e3f37
data/Gemfile CHANGED
@@ -4,3 +4,14 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in rspec-html.gemspec
6
6
  gemspec
7
+
8
+ gem 'activesupport', '~> 6.1'
9
+ gem 'bundler', '~> 2.0'
10
+ gem 'devpack', '~> 0.4.0'
11
+ gem 'i18n', '~> 1.7'
12
+ gem 'rake', '~> 13.0'
13
+ gem 'rspec-its', '~> 1.3'
14
+ gem 'rubocop', '~> 1.29'
15
+ gem 'rubocop-rake', '~> 0.6.0'
16
+ gem 'rubocop-rspec', '~> 2.10'
17
+ gem 'strong_versions', '~> 0.4.5'
data/Gemfile.lock CHANGED
@@ -1,13 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-html (0.2.18)
4
+ rspec-html (0.2.19)
5
5
  nokogiri (~> 1.10)
6
6
  rspec (~> 3.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
+ activesupport (6.1.7.3)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ zeitwerk (~> 2.3)
11
17
  ast (2.4.2)
12
18
  concurrent-ruby (1.2.2)
13
19
  devpack (0.4.1)
@@ -15,7 +21,10 @@ GEM
15
21
  i18n (1.13.0)
16
22
  concurrent-ruby (~> 1.0)
17
23
  json (2.6.3)
18
- nokogiri (1.13.10-x86_64-linux)
24
+ mini_portile2 (2.8.2)
25
+ minitest (5.18.0)
26
+ nokogiri (1.13.10)
27
+ mini_portile2 (~> 2.8.0)
19
28
  racc (~> 1.4)
20
29
  paint (2.3.0)
21
30
  parallel (1.23.0)
@@ -65,12 +74,16 @@ GEM
65
74
  strong_versions (0.4.5)
66
75
  i18n (>= 0.5)
67
76
  paint (~> 2.0)
77
+ tzinfo (2.0.6)
78
+ concurrent-ruby (~> 1.0)
68
79
  unicode-display_width (2.4.2)
80
+ zeitwerk (2.6.8)
69
81
 
70
82
  PLATFORMS
71
83
  ruby
72
84
 
73
85
  DEPENDENCIES
86
+ activesupport (~> 6.1)
74
87
  bundler (~> 2.0)
75
88
  devpack (~> 0.4.0)
76
89
  i18n (~> 1.7)
data/README.md CHANGED
@@ -109,6 +109,13 @@ To select an index from a set of matched elements use the array-style interface
109
109
  expect(document.body.div[1].span[1][:class]).to contain_text 'my-class'
110
110
  ```
111
111
 
112
+ Alternatively, use `#first`, `#last` or, when using _ActiveSupport_, `#second`, `#third`, etc. are also available:
113
+
114
+ ```ruby
115
+ expect(document.body.div.first.span.last[:class]).to contain_text 'my-class'
116
+ ```
117
+
118
+
112
119
  #### Element Existence
113
120
  To test if a matching element was found use the `exist` matcher:
114
121
  ```ruby
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module HTML
5
- VERSION = '0.2.18'
5
+ VERSION = '0.2.20'
6
6
  end
7
7
  end
@@ -3,15 +3,16 @@
3
3
  module RSpecHTML
4
4
  # HTML DOM element abstraction
5
5
  class Element
6
- attr_reader :name, :element
6
+ attr_reader :name, :element, :search
7
7
 
8
8
  extend Forwardable
9
9
 
10
10
  def_delegators :@search,
11
11
  :has_css?, :has_xpath?, :include?,
12
- :all, :siblings, :text, :truncated_text, :attributes,
12
+ :all, :siblings, :text, :truncated_text, :attributes, :to_a,
13
13
  :size, :length, :[],
14
- :css, :xpath, :checked?
14
+ :css, :xpath, :checked?,
15
+ :first, :last, :second, :third, :fourth, :fifth
15
16
 
16
17
  def initialize(element, name, options: {}, siblings: [])
17
18
  @name = name
@@ -6,6 +6,11 @@ module RSpecHTML
6
6
  class Search
7
7
  attr_reader :siblings
8
8
 
9
+ extend Forwardable
10
+
11
+ def_delegators :to_a,
12
+ :first, :last, :second, :third, :fourth, :fifth
13
+
9
14
  def initialize(element, siblings, element_wrapper)
10
15
  @element = element
11
16
  @siblings = siblings
@@ -16,6 +21,10 @@ module RSpecHTML
16
21
  @element&.to_s
17
22
  end
18
23
 
24
+ def to_a
25
+ all.to_a
26
+ end
27
+
19
28
  def include?(val)
20
29
  text.include?(val)
21
30
  end
@@ -140,7 +149,7 @@ module RSpecHTML
140
149
 
141
150
  def where_xpath(tag, query)
142
151
  conditions = "[#{where_conditions(query)}]" unless query.compact.empty?
143
- @element&.xpath("//#{tag}#{conditions}")
152
+ @element&.xpath(".//#{tag}#{conditions}")
144
153
  end
145
154
 
146
155
  def where_conditions(query)
data/rspec-html.gemspec CHANGED
@@ -31,15 +31,5 @@ Gem::Specification.new do |spec|
31
31
  spec.required_ruby_version = '>= 2.6'
32
32
  spec.add_dependency 'nokogiri', '~> 1.10'
33
33
  spec.add_dependency 'rspec', '~> 3.0'
34
-
35
- spec.add_development_dependency 'bundler', '~> 2.0'
36
- spec.add_development_dependency 'devpack', '~> 0.4.0'
37
- spec.add_development_dependency 'i18n', '~> 1.7'
38
- spec.add_development_dependency 'rake', '~> 13.0'
39
- spec.add_development_dependency 'rspec-its', '~> 1.3'
40
- spec.add_development_dependency 'rubocop', '~> 1.29'
41
- spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
42
- spec.add_development_dependency 'rubocop-rspec', '~> 2.10'
43
- spec.add_development_dependency 'strong_versions', '~> 0.4.5'
44
34
  spec.metadata['rubygems_mfa_required'] = 'true'
45
35
  end
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.18
4
+ version: 0.2.20
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-05 00:00:00.000000000 Z
11
+ date: 2023-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -38,132 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.0'
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2.0'
55
- - !ruby/object:Gem::Dependency
56
- name: devpack
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 0.4.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 0.4.0
69
- - !ruby/object:Gem::Dependency
70
- name: i18n
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.7'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.7'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '13.0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '13.0'
97
- - !ruby/object:Gem::Dependency
98
- name: rspec-its
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '1.3'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '1.3'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '1.29'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '1.29'
125
- - !ruby/object:Gem::Dependency
126
- name: rubocop-rake
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: 0.6.0
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: 0.6.0
139
- - !ruby/object:Gem::Dependency
140
- name: rubocop-rspec
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '2.10'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '2.10'
153
- - !ruby/object:Gem::Dependency
154
- name: strong_versions
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: 0.4.5
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: 0.4.5
167
41
  description: HTML document abstraction and matchers for RSpec
168
42
  email:
169
43
  - git@bob.frl