rspec-html 0.2.13 → 0.2.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -2
- 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: 01bcf5f299f82598a2836fee0f3ef8eb79af8b8219c65c74f6d130d3aa33a0e3
|
4
|
+
data.tar.gz: 8c784dec087fd10eb08a889db1e69dfaecbc1c3120347f66307ddc0071556bd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 566fbca771830a80666a798820e683ed857d01bf15c7fc147894986af724399d3b78c01e14316da5e9b3de7ed0e8a3e5a61f5de82512e7cad3c1e096809b4b0c
|
7
|
+
data.tar.gz: e12956efafa2e2a917e12640cee2bf43abe24d14f5ab9b19a87173e2e9689b83f741a50a18ece0f0dd9c82843b93c7539443a649ac431b3540a841c2158ba8f2
|
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.14)
|
5
5
|
nokogiri (~> 1.10)
|
6
6
|
rspec (~> 3.0)
|
7
7
|
|
@@ -14,7 +14,9 @@ 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.0)
|
18
|
+
nokogiri (1.13.8)
|
19
|
+
mini_portile2 (~> 2.8.0)
|
18
20
|
racc (~> 1.4)
|
19
21
|
paint (2.2.1)
|
20
22
|
parallel (1.22.1)
|
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 ArumentError, '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.14
|
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-
|
11
|
+
date: 2022-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|