rspec-html 0.2.3 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -75
- data/.ruby-version +1 -1
- data/Gemfile.lock +40 -37
- data/README.md +1 -1
- data/lib/rspec/html/version.rb +1 -1
- data/lib/rspec/html.rb +2 -4
- data/lib/rspec_html/element.rb +8 -2
- data/lib/rspec_html/matchers/base.rb +1 -1
- data/lib/rspec_html/search.rb +8 -0
- data/rspec-html.gemspec +1 -1
- data/templates/failure/contain_text.erb +2 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d97c22c301a390a13dd3faa6e259633d6c991346e35da9cb3abded233b2a3809
|
4
|
+
data.tar.gz: 10d4ce1f83f23f6a2620050a3d6cf680aab9f5c63dd59d51f2d18170140742bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4389b7626dee960fe7933446a09a72d6bf1021395184b3b6fc0a5f2afd8a7d42b40422a7a92880030cc157bd4e15961546799884bb330c90ce251ef575316ee4
|
7
|
+
data.tar.gz: d789b659fff49df36383b979b92127af11a268568687f67bcdebf7860e0b12950c93082548fb79540c513eb8b5588c7983fa27b2b34f3c986bc73b1db990ffd3
|
data/.rubocop.yml
CHANGED
@@ -6,80 +6,9 @@ Metrics/BlockLength:
|
|
6
6
|
Gemspec/RequiredRubyVersion:
|
7
7
|
Enabled: false
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
AllCops:
|
10
|
+
NewCops: enable
|
11
11
|
|
12
|
-
|
13
|
-
Enabled: true
|
14
|
-
Layout/SpaceAroundMethodCallOperator:
|
15
|
-
Enabled: true
|
16
|
-
Lint/DeprecatedOpenSSLConstant:
|
17
|
-
Enabled: true
|
18
|
-
Lint/DuplicateElsifCondition:
|
19
|
-
Enabled: true
|
20
|
-
Lint/MixedRegexpCaptureTypes:
|
21
|
-
Enabled: true
|
22
|
-
Lint/RaiseException:
|
23
|
-
Enabled: true
|
24
|
-
Lint/StructNewOverride:
|
25
|
-
Enabled: true
|
26
|
-
Style/AccessorGrouping:
|
27
|
-
Enabled: true
|
28
|
-
Style/ArrayCoercion:
|
29
|
-
Enabled: true
|
30
|
-
Style/BisectedAttrAccessor:
|
31
|
-
Enabled: true
|
32
|
-
Style/CaseLikeIf:
|
33
|
-
Enabled: true
|
34
|
-
Style/ExponentialNotation:
|
35
|
-
Enabled: true
|
36
|
-
Style/HashAsLastArrayItem:
|
37
|
-
Enabled: true
|
38
|
-
Style/HashEachMethods:
|
39
|
-
Enabled: true
|
40
|
-
Style/HashLikeCase:
|
41
|
-
Enabled: true
|
42
|
-
Style/HashTransformKeys:
|
43
|
-
Enabled: true
|
44
|
-
Style/HashTransformValues:
|
45
|
-
Enabled: true
|
46
|
-
Style/RedundantAssignment:
|
47
|
-
Enabled: true
|
48
|
-
Style/RedundantFetchBlock:
|
49
|
-
Enabled: true
|
50
|
-
Style/RedundantFileExtensionInRequire:
|
51
|
-
Enabled: true
|
52
|
-
Style/RedundantRegexpCharacterClass:
|
53
|
-
Enabled: true
|
54
|
-
Style/RedundantRegexpEscape:
|
55
|
-
Enabled: true
|
12
|
+
# Compatibility with older (< 2.6) Rubies.
|
56
13
|
Style/SlicingWithRange:
|
57
|
-
Enabled:
|
58
|
-
Lint/BinaryOperatorWithIdenticalOperands:
|
59
|
-
Enabled: true
|
60
|
-
Lint/DuplicateRescueException:
|
61
|
-
Enabled: true
|
62
|
-
Lint/EmptyConditionalBody:
|
63
|
-
Enabled: true
|
64
|
-
Lint/FloatComparison:
|
65
|
-
Enabled: true
|
66
|
-
Lint/MissingSuper:
|
67
|
-
Enabled: true
|
68
|
-
Lint/OutOfRangeRegexpRef:
|
69
|
-
Enabled: true
|
70
|
-
Lint/SelfAssignment:
|
71
|
-
Enabled: true
|
72
|
-
Lint/TopLevelReturnWithArgument:
|
73
|
-
Enabled: true
|
74
|
-
Lint/UnreachableLoop:
|
75
|
-
Enabled: true
|
76
|
-
Style/ExplicitBlockArgument:
|
77
|
-
Enabled: true
|
78
|
-
Style/GlobalStdStream:
|
79
|
-
Enabled: true
|
80
|
-
Style/OptionalBooleanParameter:
|
81
|
-
Enabled: true
|
82
|
-
Style/SingleArgumentDig:
|
83
|
-
Enabled: true
|
84
|
-
Style/StringConcatenation:
|
85
|
-
Enabled: true
|
14
|
+
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.1
|
data/Gemfile.lock
CHANGED
@@ -1,65 +1,68 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec-html (0.2.
|
4
|
+
rspec-html (0.2.7)
|
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
|
-
ast (2.4.
|
11
|
+
ast (2.4.2)
|
12
12
|
byebug (11.1.3)
|
13
|
-
concurrent-ruby (1.1.
|
14
|
-
devpack (0.1.
|
13
|
+
concurrent-ruby (1.1.9)
|
14
|
+
devpack (0.1.3)
|
15
15
|
diff-lcs (1.4.4)
|
16
|
-
i18n (1.8.
|
16
|
+
i18n (1.8.11)
|
17
17
|
concurrent-ruby (~> 1.0)
|
18
|
-
mini_portile2 (2.
|
19
|
-
nokogiri (1.
|
20
|
-
mini_portile2 (~> 2.
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
mini_portile2 (2.6.1)
|
19
|
+
nokogiri (1.12.5)
|
20
|
+
mini_portile2 (~> 2.6.1)
|
21
|
+
racc (~> 1.4)
|
22
|
+
paint (2.2.1)
|
23
|
+
parallel (1.21.0)
|
24
|
+
parser (3.0.3.2)
|
24
25
|
ast (~> 2.4.1)
|
26
|
+
racc (1.6.0)
|
25
27
|
rainbow (3.0.0)
|
26
|
-
rake (13.0.
|
27
|
-
regexp_parser (
|
28
|
-
rexml (3.2.
|
29
|
-
rspec (3.
|
30
|
-
rspec-core (~> 3.
|
31
|
-
rspec-expectations (~> 3.
|
32
|
-
rspec-mocks (~> 3.
|
33
|
-
rspec-core (3.
|
34
|
-
rspec-support (~> 3.
|
35
|
-
rspec-expectations (3.
|
28
|
+
rake (13.0.6)
|
29
|
+
regexp_parser (2.2.0)
|
30
|
+
rexml (3.2.5)
|
31
|
+
rspec (3.10.0)
|
32
|
+
rspec-core (~> 3.10.0)
|
33
|
+
rspec-expectations (~> 3.10.0)
|
34
|
+
rspec-mocks (~> 3.10.0)
|
35
|
+
rspec-core (3.10.1)
|
36
|
+
rspec-support (~> 3.10.0)
|
37
|
+
rspec-expectations (3.10.1)
|
36
38
|
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
-
rspec-support (~> 3.
|
39
|
+
rspec-support (~> 3.10.0)
|
38
40
|
rspec-its (1.3.0)
|
39
41
|
rspec-core (>= 3.0.0)
|
40
42
|
rspec-expectations (>= 3.0.0)
|
41
|
-
rspec-mocks (3.
|
43
|
+
rspec-mocks (3.10.2)
|
42
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (~> 3.
|
44
|
-
rspec-support (3.
|
45
|
-
rubocop (0.
|
45
|
+
rspec-support (~> 3.10.0)
|
46
|
+
rspec-support (3.10.3)
|
47
|
+
rubocop (0.93.1)
|
46
48
|
parallel (~> 1.10)
|
47
|
-
parser (>= 2.7.1.
|
49
|
+
parser (>= 2.7.1.5)
|
48
50
|
rainbow (>= 2.2.2, < 4.0)
|
49
|
-
regexp_parser (>= 1.
|
51
|
+
regexp_parser (>= 1.8)
|
50
52
|
rexml
|
51
|
-
rubocop-ast (>= 0.
|
53
|
+
rubocop-ast (>= 0.6.0)
|
52
54
|
ruby-progressbar (~> 1.7)
|
53
55
|
unicode-display_width (>= 1.4.0, < 2.0)
|
54
|
-
rubocop-ast (
|
55
|
-
parser (>=
|
56
|
-
rubocop-rspec (1.
|
57
|
-
rubocop (
|
58
|
-
|
56
|
+
rubocop-ast (1.15.0)
|
57
|
+
parser (>= 3.0.1.1)
|
58
|
+
rubocop-rspec (1.44.1)
|
59
|
+
rubocop (~> 0.87)
|
60
|
+
rubocop-ast (>= 0.7.1)
|
61
|
+
ruby-progressbar (1.11.0)
|
59
62
|
strong_versions (0.4.5)
|
60
63
|
i18n (>= 0.5)
|
61
64
|
paint (~> 2.0)
|
62
|
-
unicode-display_width (1.
|
65
|
+
unicode-display_width (1.8.0)
|
63
66
|
|
64
67
|
PLATFORMS
|
65
68
|
ruby
|
@@ -72,9 +75,9 @@ DEPENDENCIES
|
|
72
75
|
rake (~> 13.0)
|
73
76
|
rspec-html!
|
74
77
|
rspec-its (~> 1.3)
|
75
|
-
rubocop (~> 0.
|
78
|
+
rubocop (~> 0.93.1)
|
76
79
|
rubocop-rspec (~> 1.36)
|
77
80
|
strong_versions (~> 0.4.5)
|
78
81
|
|
79
82
|
BUNDLED WITH
|
80
|
-
2.
|
83
|
+
2.1.4
|
data/README.md
CHANGED
data/lib/rspec/html/version.rb
CHANGED
data/lib/rspec/html.rb
CHANGED
@@ -11,11 +11,9 @@ module RSpec
|
|
11
11
|
def document
|
12
12
|
return @document if @document
|
13
13
|
|
14
|
-
if !defined?(response) || response.nil?
|
15
|
-
raise RSpecHTML::NoResponseError, 'No `response` object found. Make a request first.'
|
16
|
-
end
|
17
|
-
|
18
14
|
RSpecHTML::Element.new(Nokogiri::HTML.parse(response.body), :document)
|
15
|
+
rescue NameError
|
16
|
+
raise RSpecHTML::NoResponseError, 'No `response` object found. Make a request first.'
|
19
17
|
end
|
20
18
|
|
21
19
|
def parse_html(content)
|
data/lib/rspec_html/element.rb
CHANGED
@@ -8,8 +8,7 @@ module RSpecHTML
|
|
8
8
|
extend Forwardable
|
9
9
|
|
10
10
|
def_delegators :@search,
|
11
|
-
:has_css?, :has_xpath?, :include?, :
|
12
|
-
:text, :size, :length, :[]
|
11
|
+
:has_css?, :has_xpath?, :include?, :text, :truncated_text, :size, :length, :css, :xpath, :[]
|
13
12
|
|
14
13
|
def initialize(element, name, options: {}, siblings: [])
|
15
14
|
@name = name
|
@@ -19,6 +18,13 @@ module RSpecHTML
|
|
19
18
|
@search = Search.new(@element, @siblings)
|
20
19
|
end
|
21
20
|
|
21
|
+
def present?
|
22
|
+
return true if name == :document
|
23
|
+
|
24
|
+
@search.present?
|
25
|
+
end
|
26
|
+
alias exist? present?
|
27
|
+
|
22
28
|
def inspect
|
23
29
|
"<#{self.class}::#{name.to_s.capitalize}>"
|
24
30
|
end
|
data/lib/rspec_html/search.rb
CHANGED
@@ -46,6 +46,13 @@ module RSpecHTML
|
|
46
46
|
@element&.text&.gsub(/\s+/, ' ')&.strip || ''
|
47
47
|
end
|
48
48
|
|
49
|
+
def truncated_text
|
50
|
+
max = RSpec::Support::ObjectFormatter.default_instance.max_formatted_output_length
|
51
|
+
return text if text.size <= max
|
52
|
+
|
53
|
+
"#{text[0..max]}...#{text[-max..-1]}"
|
54
|
+
end
|
55
|
+
|
49
56
|
def size
|
50
57
|
return @element.size if @element.respond_to?(:size)
|
51
58
|
|
@@ -93,6 +100,7 @@ module RSpecHTML
|
|
93
100
|
else
|
94
101
|
where_xpath(tag, query)
|
95
102
|
end
|
103
|
+
return nil unless matched || all
|
96
104
|
return matched&.first unless all
|
97
105
|
|
98
106
|
matched
|
data/rspec-html.gemspec
CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
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', '~> 0.
|
40
|
+
spec.add_development_dependency 'rubocop', '~> 0.93.1'
|
41
41
|
spec.add_development_dependency 'rubocop-rspec', '~> 1.36'
|
42
42
|
spec.add_development_dependency 'strong_versions', '~> 0.4.5'
|
43
43
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<%
|
1
|
+
<% unless actual.exist? %>
|
2
2
|
Expected <%= actual.reconstituted %> to contain <%= expected.inspect %> but the element did not exist.
|
3
3
|
<% else %>
|
4
|
-
Expected text in <%= actual.reconstituted %> <%= (actual.
|
4
|
+
Expected text in <%= actual.reconstituted %> <%= (actual.truncated_text).inspect %> to contain <%= expected.inspect %> but it did not.
|
5
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.
|
131
|
+
version: 0.93.1
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.
|
138
|
+
version: 0.93.1
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rubocop-rspec
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,7 +207,7 @@ metadata:
|
|
207
207
|
homepage_uri: https://github.com/bobf/rspec-html
|
208
208
|
source_code_uri: https://github.com/bobf/rspec-html
|
209
209
|
changelog_uri: https://github.com/bobf/rspec-html/blob/master/LICENSE
|
210
|
-
post_install_message:
|
210
|
+
post_install_message:
|
211
211
|
rdoc_options: []
|
212
212
|
require_paths:
|
213
213
|
- lib
|
@@ -222,8 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
222
|
- !ruby/object:Gem::Version
|
223
223
|
version: '0'
|
224
224
|
requirements: []
|
225
|
-
rubygems_version: 3.
|
226
|
-
signing_key:
|
225
|
+
rubygems_version: 3.1.2
|
226
|
+
signing_key:
|
227
227
|
specification_version: 4
|
228
228
|
summary: RSpec HTML
|
229
229
|
test_files: []
|