rspec-html 0.2.13 → 0.2.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -4
- data/README.md +5 -0
- data/lib/rspec/html/version.rb +1 -1
- data/lib/rspec_html/element.rb +1 -1
- data/lib/rspec_html/matchers/match_text.rb +5 -0
- data/lib/rspec_html/search.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f365aa23d4ca954b964195b0d47f929a99b71fc2b976407ca9d225f70c5ea4c
|
4
|
+
data.tar.gz: 1f3333b370b7e03e205eeabd8dab11050137652d4267ca14bfbff8098920d4d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff59e58090b970db24849dc4c715ff3e0748c364bbbc11cdfd9fa8a078cb938aea9bebe329e0c8e1c1a4a943bbf2962bff96ffb23c353381b6cda864f98b770a
|
7
|
+
data.tar.gz: 26291ba3e7932df4ca2ef3cb9bbf52bbd8b89daeb8d90cd2e133290534e97ee9673bc766c9fc0d81c46b21f7f75dbb349bfdf017ee1e29de27e4cfc1e51126ec
|
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.15)
|
5
5
|
nokogiri (~> 1.10)
|
6
6
|
rspec (~> 3.0)
|
7
7
|
|
@@ -14,13 +14,15 @@ GEM
|
|
14
14
|
diff-lcs (1.5.0)
|
15
15
|
i18n (1.10.0)
|
16
16
|
concurrent-ruby (~> 1.0)
|
17
|
-
|
17
|
+
mini_portile2 (2.8.1)
|
18
|
+
nokogiri (1.13.10)
|
19
|
+
mini_portile2 (~> 2.8.0)
|
18
20
|
racc (~> 1.4)
|
19
21
|
paint (2.2.1)
|
20
22
|
parallel (1.22.1)
|
21
23
|
parser (3.1.2.0)
|
22
24
|
ast (~> 2.4.1)
|
23
|
-
racc (1.6.
|
25
|
+
racc (1.6.2)
|
24
26
|
rainbow (3.1.1)
|
25
27
|
rake (13.0.6)
|
26
28
|
regexp_parser (2.3.1)
|
@@ -37,7 +39,7 @@ GEM
|
|
37
39
|
rspec-its (1.3.0)
|
38
40
|
rspec-core (>= 3.0.0)
|
39
41
|
rspec-expectations (>= 3.0.0)
|
40
|
-
rspec-mocks (3.11.
|
42
|
+
rspec-mocks (3.11.2)
|
41
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
42
44
|
rspec-support (~> 3.11.0)
|
43
45
|
rspec-support (3.11.0)
|
data/README.md
CHANGED
@@ -59,6 +59,11 @@ To select an element matching certain attributes pass a hash to any of the chain
|
|
59
59
|
expect(document.body.div(id: 'my-div').span(align: 'left')).to contain_text 'some text'
|
60
60
|
```
|
61
61
|
|
62
|
+
Special attributes like `checked` can be found using the `#attributes` method:
|
63
|
+
```ruby
|
64
|
+
expect(document.input(type: 'checkbox', name: 'my-name')).attributes).to include 'checked'
|
65
|
+
```
|
66
|
+
|
62
67
|
#### Class Matching
|
63
68
|
_CSS_ classes are treated as a special case: to select an element matching a set of classes pass the `class` parameter:
|
64
69
|
```ruby
|
data/lib/rspec/html/version.rb
CHANGED
data/lib/rspec_html/element.rb
CHANGED
@@ -9,6 +9,7 @@ module RSpecHTML
|
|
9
9
|
diffable
|
10
10
|
|
11
11
|
def match(actual)
|
12
|
+
raise_argument_error unless actual.is_a?(RSpecHTML::Element)
|
12
13
|
@rspec_actual = actual&.text
|
13
14
|
return regexp_match?(actual) || regexp_siblings_match?(actual) if @expected.is_a?(Regexp)
|
14
15
|
|
@@ -32,6 +33,10 @@ module RSpecHTML
|
|
32
33
|
def string_siblings_match?(actual)
|
33
34
|
actual.siblings.any? { |sibling| (sibling&.text || '').include?(@expected.to_s) }
|
34
35
|
end
|
36
|
+
|
37
|
+
def raise_argument_error
|
38
|
+
raise ArgumentError, 'Expected RSpecHTML::Element with `match_text` matcher.'
|
39
|
+
end
|
35
40
|
end
|
36
41
|
end
|
37
42
|
end
|
data/lib/rspec_html/search.rb
CHANGED
@@ -11,6 +11,10 @@ module RSpecHTML
|
|
11
11
|
@siblings = siblings
|
12
12
|
end
|
13
13
|
|
14
|
+
def to_s
|
15
|
+
@element&.to_s
|
16
|
+
end
|
17
|
+
|
14
18
|
def include?(val)
|
15
19
|
text.include?(val)
|
16
20
|
end
|
@@ -56,6 +60,10 @@ module RSpecHTML
|
|
56
60
|
"#{text[0..max]}...#{text[-max..-1]}"
|
57
61
|
end
|
58
62
|
|
63
|
+
def attributes
|
64
|
+
@element&.attributes&.to_h { |key, val| [key.to_sym, val.to_s] } || {}
|
65
|
+
end
|
66
|
+
|
59
67
|
def size
|
60
68
|
return @element.size if @element.respond_to?(:size)
|
61
69
|
|
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.15
|
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: 2023-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|