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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b32fbdddde32e9e09c268a609b9491a616442c4817c729e530a57085d908027
4
- data.tar.gz: d38316dc4ba034dc06d15569ce0865fc8e342db728d4f3fbfc19fb27331a35db
3
+ metadata.gz: 01bcf5f299f82598a2836fee0f3ef8eb79af8b8219c65c74f6d130d3aa33a0e3
4
+ data.tar.gz: 8c784dec087fd10eb08a889db1e69dfaecbc1c3120347f66307ddc0071556bd4
5
5
  SHA512:
6
- metadata.gz: 2b5d891c6b6088337c89e9d5db30a2055124416d602804390d14e1d6a7774ea726b96ffe958977208f4204efaf1a4845801ee188c9be83d2bf275d487b72a483
7
- data.tar.gz: 11ede37a337b267e453b4c105645f831f1996f590f5380f6d282fb705555c90a92e0c2af8ef43472bbcff3bd734df27e9548f6450616296f61e9e11f0827ecaf
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.12)
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
- nokogiri (1.13.6-x86_64-linux)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module HTML
5
- VERSION = '0.2.13'
5
+ VERSION = '0.2.14'
6
6
  end
7
7
  end
@@ -9,7 +9,7 @@ module RSpecHTML
9
9
 
10
10
  def_delegators :@search,
11
11
  :has_css?, :has_xpath?, :include?,
12
- :siblings, :text, :truncated_text,
12
+ :siblings, :text, :truncated_text, :attributes,
13
13
  :size, :length, :[],
14
14
  :css, :xpath
15
15
 
@@ -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
@@ -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.13
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-06-13 00:00:00.000000000 Z
11
+ date: 2022-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri