rspec-html 0.2.7 → 0.2.8
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 +4 -4
- data/.rubocop.yml +0 -3
- data/.ruby-version +1 -1
- data/Gemfile.lock +39 -41
- data/README.md +7 -4
- data/lib/rspec/html/version.rb +1 -1
- data/lib/rspec_html/matchers/contain_text.rb +3 -1
- data/lib/rspec_html/matchers/match_text.rb +19 -0
- data/lib/rspec_html/matchers.rb +2 -0
- data/lib/rspec_html.rb +1 -0
- data/rspec-html.gemspec +6 -4
- data/templates/description/match_text.erb +1 -0
- data/templates/failure/match_text.erb +5 -0
- metadata +28 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a271ab933a02e1c5456ea472551e09d194132d79d9f47924cc8aa9cc4ae9c832
|
|
4
|
+
data.tar.gz: 230f1ae1e54404f1766b909074bea3d0b83d748f8a57a7df9c497a60137c4fc4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad8a71ee657b000eb1b334d365da8f723ec0466c69aa7580b8104c87aae23066ca703cdbbea3717ac3b422fb57b59c8784ecef4a8eeb3366a0f719bd5f2808eb
|
|
7
|
+
data.tar.gz: a1eeede78f3c7bddc433c2162c4355779c55bd9c6c0ce984f42ad347eaef3e8c5cc22e7b78dbe29450a353c8acd679a24acaccd4a6add6981223ba90eaf45901
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.6.9
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rspec-html (0.2.
|
|
4
|
+
rspec-html (0.2.8)
|
|
5
5
|
nokogiri (~> 1.10)
|
|
6
6
|
rspec (~> 3.0)
|
|
7
7
|
|
|
@@ -9,75 +9,73 @@ GEM
|
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
11
|
ast (2.4.2)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
i18n (1.8.11)
|
|
12
|
+
concurrent-ruby (1.1.10)
|
|
13
|
+
devpack (0.4.0)
|
|
14
|
+
diff-lcs (1.5.0)
|
|
15
|
+
i18n (1.10.0)
|
|
17
16
|
concurrent-ruby (~> 1.0)
|
|
18
|
-
|
|
19
|
-
nokogiri (1.12.5)
|
|
20
|
-
mini_portile2 (~> 2.6.1)
|
|
17
|
+
nokogiri (1.13.5-x86_64-linux)
|
|
21
18
|
racc (~> 1.4)
|
|
22
19
|
paint (2.2.1)
|
|
23
|
-
parallel (1.
|
|
24
|
-
parser (3.
|
|
20
|
+
parallel (1.22.1)
|
|
21
|
+
parser (3.1.2.0)
|
|
25
22
|
ast (~> 2.4.1)
|
|
26
23
|
racc (1.6.0)
|
|
27
|
-
rainbow (3.
|
|
24
|
+
rainbow (3.1.1)
|
|
28
25
|
rake (13.0.6)
|
|
29
|
-
regexp_parser (2.
|
|
26
|
+
regexp_parser (2.3.1)
|
|
30
27
|
rexml (3.2.5)
|
|
31
|
-
rspec (3.
|
|
32
|
-
rspec-core (~> 3.
|
|
33
|
-
rspec-expectations (~> 3.
|
|
34
|
-
rspec-mocks (~> 3.
|
|
35
|
-
rspec-core (3.
|
|
36
|
-
rspec-support (~> 3.
|
|
37
|
-
rspec-expectations (3.
|
|
28
|
+
rspec (3.11.0)
|
|
29
|
+
rspec-core (~> 3.11.0)
|
|
30
|
+
rspec-expectations (~> 3.11.0)
|
|
31
|
+
rspec-mocks (~> 3.11.0)
|
|
32
|
+
rspec-core (3.11.0)
|
|
33
|
+
rspec-support (~> 3.11.0)
|
|
34
|
+
rspec-expectations (3.11.0)
|
|
38
35
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
39
|
-
rspec-support (~> 3.
|
|
36
|
+
rspec-support (~> 3.11.0)
|
|
40
37
|
rspec-its (1.3.0)
|
|
41
38
|
rspec-core (>= 3.0.0)
|
|
42
39
|
rspec-expectations (>= 3.0.0)
|
|
43
|
-
rspec-mocks (3.
|
|
40
|
+
rspec-mocks (3.11.1)
|
|
44
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
45
|
-
rspec-support (~> 3.
|
|
46
|
-
rspec-support (3.
|
|
47
|
-
rubocop (
|
|
42
|
+
rspec-support (~> 3.11.0)
|
|
43
|
+
rspec-support (3.11.0)
|
|
44
|
+
rubocop (1.29.0)
|
|
48
45
|
parallel (~> 1.10)
|
|
49
|
-
parser (>=
|
|
46
|
+
parser (>= 3.1.0.0)
|
|
50
47
|
rainbow (>= 2.2.2, < 4.0)
|
|
51
|
-
regexp_parser (>= 1.8)
|
|
52
|
-
rexml
|
|
53
|
-
rubocop-ast (>=
|
|
48
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
49
|
+
rexml (>= 3.2.5, < 4.0)
|
|
50
|
+
rubocop-ast (>= 1.17.0, < 2.0)
|
|
54
51
|
ruby-progressbar (~> 1.7)
|
|
55
|
-
unicode-display_width (>= 1.4.0, <
|
|
56
|
-
rubocop-ast (1.
|
|
57
|
-
parser (>= 3.
|
|
58
|
-
rubocop-
|
|
59
|
-
rubocop (~> 0
|
|
60
|
-
|
|
52
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
53
|
+
rubocop-ast (1.17.0)
|
|
54
|
+
parser (>= 3.1.1.0)
|
|
55
|
+
rubocop-rake (0.6.0)
|
|
56
|
+
rubocop (~> 1.0)
|
|
57
|
+
rubocop-rspec (2.10.0)
|
|
58
|
+
rubocop (~> 1.19)
|
|
61
59
|
ruby-progressbar (1.11.0)
|
|
62
60
|
strong_versions (0.4.5)
|
|
63
61
|
i18n (>= 0.5)
|
|
64
62
|
paint (~> 2.0)
|
|
65
|
-
unicode-display_width (1.
|
|
63
|
+
unicode-display_width (2.1.0)
|
|
66
64
|
|
|
67
65
|
PLATFORMS
|
|
68
66
|
ruby
|
|
69
67
|
|
|
70
68
|
DEPENDENCIES
|
|
71
69
|
bundler (~> 2.0)
|
|
72
|
-
|
|
73
|
-
devpack (~> 0.1.2)
|
|
70
|
+
devpack (~> 0.4.0)
|
|
74
71
|
i18n (~> 1.7)
|
|
75
72
|
rake (~> 13.0)
|
|
76
73
|
rspec-html!
|
|
77
74
|
rspec-its (~> 1.3)
|
|
78
|
-
rubocop (~>
|
|
79
|
-
rubocop-
|
|
75
|
+
rubocop (~> 1.29)
|
|
76
|
+
rubocop-rake (~> 0.6.0)
|
|
77
|
+
rubocop-rspec (~> 2.10)
|
|
80
78
|
strong_versions (~> 0.4.5)
|
|
81
79
|
|
|
82
80
|
BUNDLED WITH
|
|
83
|
-
2.
|
|
81
|
+
2.3.11
|
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
|
+
gem 'rspec-html', '~> 0.2.8'
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
And rebuild your bundle:
|
|
@@ -112,12 +112,15 @@ expect(document.body).to have_xpath '//html/body/div[@class="myclass"]'
|
|
|
112
112
|
### Custom Matchers
|
|
113
113
|
<a name="matchers"></a>
|
|
114
114
|
|
|
115
|
-
####
|
|
115
|
+
#### match_text
|
|
116
116
|
|
|
117
|
-
Use the `
|
|
117
|
+
Use the `match_text` matcher to locate text within a _DOM_ element. All mark-up elements are stripped when using this matcher.
|
|
118
|
+
|
|
119
|
+
This matcher receives either a string or a regular expression.
|
|
118
120
|
|
|
119
121
|
```ruby
|
|
120
|
-
expect(document.body.form).to
|
|
122
|
+
expect(document.body.form).to match_text 'Please enter your password'
|
|
123
|
+
expect(document.body.form).to match_text /Please enter your [a-z]+/
|
|
121
124
|
```
|
|
122
125
|
|
|
123
126
|
#### contain_tag
|
data/lib/rspec/html/version.rb
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
module RSpecHTML
|
|
4
4
|
module Matchers
|
|
5
|
-
# Matches text within a given DOM element.
|
|
5
|
+
# Matches text within a given DOM element (strips HTML tags and compares text content only).
|
|
6
|
+
# (Deprecated in favour of `#match_text`.
|
|
6
7
|
class ContainText
|
|
7
8
|
include Base
|
|
8
9
|
|
|
9
10
|
diffable
|
|
10
11
|
|
|
11
12
|
def match(actual)
|
|
13
|
+
warn('[rspec-html] The `contain_text` matcher is deprecated. Use `match_text` instead.')
|
|
12
14
|
@rspec_actual = actual&.text
|
|
13
15
|
(actual&.text || '').include?(@expected.to_s)
|
|
14
16
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RSpecHTML
|
|
4
|
+
module Matchers
|
|
5
|
+
# Matches text or regex within a given DOM element (strips HTML tags and compares text content only).
|
|
6
|
+
class MatchText
|
|
7
|
+
include Base
|
|
8
|
+
|
|
9
|
+
diffable
|
|
10
|
+
|
|
11
|
+
def match(actual)
|
|
12
|
+
@rspec_actual = actual&.text
|
|
13
|
+
return (actual&.text || '').include?(@expected.to_s) unless @expected.is_a?(Regexp)
|
|
14
|
+
|
|
15
|
+
@expected.match(actual&.text || '')
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/rspec_html/matchers.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require 'rspec_html/matchers/base'
|
|
4
4
|
require 'rspec_html/matchers/contain_text'
|
|
5
5
|
require 'rspec_html/matchers/contain_tag'
|
|
6
|
+
require 'rspec_html/matchers/match_text'
|
|
6
7
|
|
|
7
8
|
module RSpecHTML
|
|
8
9
|
# Provides matchers for identifying elements and text within a DOM element.
|
|
@@ -29,5 +30,6 @@ module RSpecHTML
|
|
|
29
30
|
|
|
30
31
|
define_matcher(:contain_text, ContainText)
|
|
31
32
|
define_matcher(:contain_tag, ContainTag)
|
|
33
|
+
define_matcher(:match_text, MatchText)
|
|
32
34
|
end
|
|
33
35
|
end
|
data/lib/rspec_html.rb
CHANGED
data/rspec-html.gemspec
CHANGED
|
@@ -28,16 +28,18 @@ Gem::Specification.new do |spec|
|
|
|
28
28
|
spec.executables = []
|
|
29
29
|
spec.require_paths = ['lib']
|
|
30
30
|
|
|
31
|
+
spec.required_ruby_version = '>= 2.6'
|
|
31
32
|
spec.add_dependency 'nokogiri', '~> 1.10'
|
|
32
33
|
spec.add_dependency 'rspec', '~> 3.0'
|
|
33
34
|
|
|
34
35
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
35
|
-
spec.add_development_dependency '
|
|
36
|
-
spec.add_development_dependency 'devpack', '~> 0.1.2'
|
|
36
|
+
spec.add_development_dependency 'devpack', '~> 0.4.0'
|
|
37
37
|
spec.add_development_dependency 'i18n', '~> 1.7'
|
|
38
38
|
spec.add_development_dependency 'rake', '~> 13.0'
|
|
39
39
|
spec.add_development_dependency 'rspec-its', '~> 1.3'
|
|
40
|
-
spec.add_development_dependency 'rubocop', '~>
|
|
41
|
-
spec.add_development_dependency 'rubocop-
|
|
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'
|
|
42
43
|
spec.add_development_dependency 'strong_versions', '~> 0.4.5'
|
|
44
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
43
45
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
match text <%= expected.inspect %>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<% unless actual.exist? %>
|
|
2
|
+
Expected <%= actual.reconstituted %> to match <%= expected.inspect %> but the element did not exist.
|
|
3
|
+
<% else %>
|
|
4
|
+
Expected text in <%= actual.reconstituted %> <%= (actual.truncated_text).inspect %> to match <%= expected.inspect %> but it did not.
|
|
5
|
+
<% 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.
|
|
4
|
+
version: 0.2.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bob Farrell
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-05-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|
|
@@ -52,34 +52,20 @@ dependencies:
|
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '2.0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: byebug
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - "~>"
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '11.0'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '11.0'
|
|
69
55
|
- !ruby/object:Gem::Dependency
|
|
70
56
|
name: devpack
|
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
|
72
58
|
requirements:
|
|
73
59
|
- - "~>"
|
|
74
60
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0.
|
|
61
|
+
version: 0.4.0
|
|
76
62
|
type: :development
|
|
77
63
|
prerelease: false
|
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
65
|
requirements:
|
|
80
66
|
- - "~>"
|
|
81
67
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.
|
|
68
|
+
version: 0.4.0
|
|
83
69
|
- !ruby/object:Gem::Dependency
|
|
84
70
|
name: i18n
|
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -128,28 +114,42 @@ dependencies:
|
|
|
128
114
|
requirements:
|
|
129
115
|
- - "~>"
|
|
130
116
|
- !ruby/object:Gem::Version
|
|
131
|
-
version:
|
|
117
|
+
version: '1.29'
|
|
132
118
|
type: :development
|
|
133
119
|
prerelease: false
|
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
121
|
requirements:
|
|
136
122
|
- - "~>"
|
|
137
123
|
- !ruby/object:Gem::Version
|
|
138
|
-
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
139
|
- !ruby/object:Gem::Dependency
|
|
140
140
|
name: rubocop-rspec
|
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
|
142
142
|
requirements:
|
|
143
143
|
- - "~>"
|
|
144
144
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: '
|
|
145
|
+
version: '2.10'
|
|
146
146
|
type: :development
|
|
147
147
|
prerelease: false
|
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
|
149
149
|
requirements:
|
|
150
150
|
- - "~>"
|
|
151
151
|
- !ruby/object:Gem::Version
|
|
152
|
-
version: '
|
|
152
|
+
version: '2.10'
|
|
153
153
|
- !ruby/object:Gem::Dependency
|
|
154
154
|
name: strong_versions
|
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -192,14 +192,17 @@ files:
|
|
|
192
192
|
- lib/rspec_html/matchers/base.rb
|
|
193
193
|
- lib/rspec_html/matchers/contain_tag.rb
|
|
194
194
|
- lib/rspec_html/matchers/contain_text.rb
|
|
195
|
+
- lib/rspec_html/matchers/match_text.rb
|
|
195
196
|
- lib/rspec_html/reconstituted_element.rb
|
|
196
197
|
- lib/rspec_html/search.rb
|
|
197
198
|
- lib/rspec_html/tags.rb
|
|
198
199
|
- rspec-html.gemspec
|
|
199
200
|
- templates/description/contain_tag.erb
|
|
200
201
|
- templates/description/contain_text.erb
|
|
202
|
+
- templates/description/match_text.erb
|
|
201
203
|
- templates/failure/contain_tag.erb
|
|
202
204
|
- templates/failure/contain_text.erb
|
|
205
|
+
- templates/failure/match_text.erb
|
|
203
206
|
homepage: https://github.com/bobf/rspec-html
|
|
204
207
|
licenses:
|
|
205
208
|
- MIT
|
|
@@ -207,6 +210,7 @@ metadata:
|
|
|
207
210
|
homepage_uri: https://github.com/bobf/rspec-html
|
|
208
211
|
source_code_uri: https://github.com/bobf/rspec-html
|
|
209
212
|
changelog_uri: https://github.com/bobf/rspec-html/blob/master/LICENSE
|
|
213
|
+
rubygems_mfa_required: 'true'
|
|
210
214
|
post_install_message:
|
|
211
215
|
rdoc_options: []
|
|
212
216
|
require_paths:
|
|
@@ -215,14 +219,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
215
219
|
requirements:
|
|
216
220
|
- - ">="
|
|
217
221
|
- !ruby/object:Gem::Version
|
|
218
|
-
version: '
|
|
222
|
+
version: '2.6'
|
|
219
223
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
224
|
requirements:
|
|
221
225
|
- - ">="
|
|
222
226
|
- !ruby/object:Gem::Version
|
|
223
227
|
version: '0'
|
|
224
228
|
requirements: []
|
|
225
|
-
rubygems_version: 3.1
|
|
229
|
+
rubygems_version: 3.0.3.1
|
|
226
230
|
signing_key:
|
|
227
231
|
specification_version: 4
|
|
228
232
|
summary: RSpec HTML
|