rspec-html 0.2.14 → 0.2.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01bcf5f299f82598a2836fee0f3ef8eb79af8b8219c65c74f6d130d3aa33a0e3
4
- data.tar.gz: 8c784dec087fd10eb08a889db1e69dfaecbc1c3120347f66307ddc0071556bd4
3
+ metadata.gz: 7f6a37320c65c9b804bc9e168b9b4db87c870fb41e65d8e87c01d63a706a4b22
4
+ data.tar.gz: 27235c7b257a78227b616222bbced4d2478a422a243d07a09bfa35eaeec81385
5
5
  SHA512:
6
- metadata.gz: 566fbca771830a80666a798820e683ed857d01bf15c7fc147894986af724399d3b78c01e14316da5e9b3de7ed0e8a3e5a61f5de82512e7cad3c1e096809b4b0c
7
- data.tar.gz: e12956efafa2e2a917e12640cee2bf43abe24d14f5ab9b19a87173e2e9689b83f741a50a18ece0f0dd9c82843b93c7539443a649ac431b3540a841c2158ba8f2
6
+ metadata.gz: 4aada61bea34ef005d8d7703ea22946f006040814413a7bf4a1983bd7f1a058dbde51db12b3a46437e7ba27db65fe478f345db03cc6f7e6c29d91af2ffebff8c
7
+ data.tar.gz: 1bffb5835af37747cb144d82dae156f8e28b01af94312db10655f49208ee7e7ac6a9baede7656edd4c07ae667e0ba20c707cfa91c25dfcfb44716d5c52842017
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-html (0.2.14)
4
+ rspec-html (0.2.16)
5
5
  nokogiri (~> 1.10)
6
6
  rspec (~> 3.0)
7
7
 
@@ -9,60 +9,63 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  ast (2.4.2)
12
- concurrent-ruby (1.1.10)
13
- devpack (0.4.0)
12
+ concurrent-ruby (1.2.2)
13
+ devpack (0.4.1)
14
14
  diff-lcs (1.5.0)
15
- i18n (1.10.0)
15
+ i18n (1.13.0)
16
16
  concurrent-ruby (~> 1.0)
17
- mini_portile2 (2.8.0)
18
- nokogiri (1.13.8)
19
- mini_portile2 (~> 2.8.0)
17
+ json (2.6.3)
18
+ nokogiri (1.13.10-x86_64-linux)
20
19
  racc (~> 1.4)
21
- paint (2.2.1)
22
- parallel (1.22.1)
23
- parser (3.1.2.0)
20
+ paint (2.3.0)
21
+ parallel (1.23.0)
22
+ parser (3.2.2.1)
24
23
  ast (~> 2.4.1)
25
- racc (1.6.0)
24
+ racc (1.6.2)
26
25
  rainbow (3.1.1)
27
26
  rake (13.0.6)
28
- regexp_parser (2.3.1)
27
+ regexp_parser (2.8.0)
29
28
  rexml (3.2.5)
30
- rspec (3.11.0)
31
- rspec-core (~> 3.11.0)
32
- rspec-expectations (~> 3.11.0)
33
- rspec-mocks (~> 3.11.0)
34
- rspec-core (3.11.0)
35
- rspec-support (~> 3.11.0)
36
- rspec-expectations (3.11.0)
29
+ rspec (3.12.0)
30
+ rspec-core (~> 3.12.0)
31
+ rspec-expectations (~> 3.12.0)
32
+ rspec-mocks (~> 3.12.0)
33
+ rspec-core (3.12.2)
34
+ rspec-support (~> 3.12.0)
35
+ rspec-expectations (3.12.3)
37
36
  diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.11.0)
37
+ rspec-support (~> 3.12.0)
39
38
  rspec-its (1.3.0)
40
39
  rspec-core (>= 3.0.0)
41
40
  rspec-expectations (>= 3.0.0)
42
- rspec-mocks (3.11.1)
41
+ rspec-mocks (3.12.5)
43
42
  diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.11.0)
45
- rspec-support (3.11.0)
46
- rubocop (1.29.0)
43
+ rspec-support (~> 3.12.0)
44
+ rspec-support (3.12.0)
45
+ rubocop (1.50.2)
46
+ json (~> 2.3)
47
47
  parallel (~> 1.10)
48
- parser (>= 3.1.0.0)
48
+ parser (>= 3.2.0.0)
49
49
  rainbow (>= 2.2.2, < 4.0)
50
50
  regexp_parser (>= 1.8, < 3.0)
51
51
  rexml (>= 3.2.5, < 4.0)
52
- rubocop-ast (>= 1.17.0, < 2.0)
52
+ rubocop-ast (>= 1.28.0, < 2.0)
53
53
  ruby-progressbar (~> 1.7)
54
- unicode-display_width (>= 1.4.0, < 3.0)
55
- rubocop-ast (1.17.0)
56
- parser (>= 3.1.1.0)
54
+ unicode-display_width (>= 2.4.0, < 3.0)
55
+ rubocop-ast (1.28.0)
56
+ parser (>= 3.2.1.0)
57
+ rubocop-capybara (2.18.0)
58
+ rubocop (~> 1.41)
57
59
  rubocop-rake (0.6.0)
58
60
  rubocop (~> 1.0)
59
- rubocop-rspec (2.10.0)
60
- rubocop (~> 1.19)
61
- ruby-progressbar (1.11.0)
61
+ rubocop-rspec (2.20.0)
62
+ rubocop (~> 1.33)
63
+ rubocop-capybara (~> 2.17)
64
+ ruby-progressbar (1.13.0)
62
65
  strong_versions (0.4.5)
63
66
  i18n (>= 0.5)
64
67
  paint (~> 2.0)
65
- unicode-display_width (2.1.0)
68
+ unicode-display_width (2.4.2)
66
69
 
67
70
  PLATFORMS
68
71
  ruby
data/README.md CHANGED
@@ -130,6 +130,13 @@ expect(document.body).to have_css 'html body div.myclass'
130
130
  expect(document.body).to have_xpath '//html/body/div[@class="myclass"]'
131
131
  ```
132
132
 
133
+ #### Checkboxes
134
+
135
+ Use `be_checked` to test if a checkbox is checked:
136
+ ```ruby
137
+ expect(document.input(type: 'checkbox')).to be_checked
138
+ ```
139
+
133
140
  ### Custom Matchers
134
141
  <a name="matchers"></a>
135
142
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module HTML
5
- VERSION = '0.2.14'
5
+ VERSION = '0.2.16'
6
6
  end
7
7
  end
@@ -11,14 +11,14 @@ module RSpecHTML
11
11
  :has_css?, :has_xpath?, :include?,
12
12
  :siblings, :text, :truncated_text, :attributes,
13
13
  :size, :length, :[],
14
- :css, :xpath
14
+ :css, :xpath, :checked?
15
15
 
16
16
  def initialize(element, name, options: {}, siblings: [])
17
17
  @name = name
18
18
  @element = element
19
19
  @options = options
20
20
  @siblings = siblings || []
21
- @search = Search.new(@element, @siblings)
21
+ @search = Search.new(@element, @siblings, self)
22
22
  end
23
23
 
24
24
  def present?
@@ -35,7 +35,7 @@ module RSpecHTML
35
35
  end
36
36
 
37
37
  def raise_argument_error
38
- raise ArumentError, 'Expected RSpecHTML::Element with `match_text` matcher.'
38
+ raise ArgumentError, 'Expected RSpecHTML::Element with `match_text` matcher.'
39
39
  end
40
40
  end
41
41
  end
@@ -6,9 +6,10 @@ module RSpecHTML
6
6
  class Search
7
7
  attr_reader :siblings
8
8
 
9
- def initialize(element, siblings)
9
+ def initialize(element, siblings, element_wrapper)
10
10
  @element = element
11
11
  @siblings = siblings
12
+ @element_wrapper = element_wrapper
12
13
  end
13
14
 
14
15
  def to_s
@@ -32,6 +33,12 @@ module RSpecHTML
32
33
  end
33
34
  alias exist? present?
34
35
 
36
+ def checked?
37
+ raise ElementNotFoundError, "Element does not exist: #{element_wrapper.reconstituted}" if @element.nil?
38
+
39
+ @element.attributes.key?('checked')
40
+ end
41
+
35
42
  # rubocop:disable Naming/PredicateName
36
43
  def has_css?(*args)
37
44
  !@element&.css(*args)&.empty?
@@ -91,14 +98,16 @@ module RSpecHTML
91
98
 
92
99
  private
93
100
 
101
+ attr_reader :element_wrapper
102
+
94
103
  def index(val)
95
104
  zero_index_error if val.zero?
96
- self.class.new(@siblings[val - 1], @element.name)
105
+ self.class.new(@siblings[val - 1], @element.name, element_wrapper)
97
106
  end
98
107
 
99
108
  def range(val)
100
109
  zero_index_error if val.first.zero?
101
- self.class.new(@siblings[(val.first - 1)..(val.last - 1)], :range)
110
+ self.class.new(@siblings[(val.first - 1)..(val.last - 1)], :range, element_wrapper)
102
111
  end
103
112
 
104
113
  def zero_index_error
data/lib/rspec_html.rb CHANGED
@@ -15,6 +15,7 @@ require 'rspec_html/matchers'
15
15
  module RSpecHTML
16
16
  class Error < StandardError; end
17
17
  class NoResponseError < Error; end
18
+ class ElementNotFoundError < Error; end
18
19
 
19
20
  def self.root
20
21
  Pathname.new(__dir__).parent
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.14
4
+ version: 0.2.16
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-07-30 00:00:00.000000000 Z
11
+ date: 2023-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri