rspec-html 0.2.4 → 0.2.5

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: 0a4eb8267f67461e6bf75c22f0081645e45fcc476ded134e74f4ad94c43ef3c7
4
- data.tar.gz: fe89ae31807178931a998f9db7ff5adbe151422620b5862814c42012e42891cb
3
+ metadata.gz: a5241cc27dba3e36c05cd7595280908be306d659d6611e02b70d58984a2f8900
4
+ data.tar.gz: 18e5487083e27fe812565b15c0411026ba622cb82c0bbbeb36787167928dab48
5
5
  SHA512:
6
- metadata.gz: 4792ec9e89160e73325604e2cc120627065ea6087124dec317e67ae519e51023c7fcd7aa6afbf04471d465fa5ed4ca4b8dd7f67ca6d605041919a00fb1319b73
7
- data.tar.gz: 690eb9f50109db6d7f89b8057e8e2aa5fa68692396dbebaecc19f8321cec4711c811bf98c6474e862eb34c50f47152de40c784ed67b682f1942055e1e1feabca
6
+ metadata.gz: 39065b13e1a1d959fcebecc3004b20e2940b560c06a9789d39b1ffa99c249f4cb0062c3888ed6af69e44d2523ff8ed4ea66989c4e35e3e924764610c51900414
7
+ data.tar.gz: 4c275980c39e8f9506a03cbb8ceca6bfdf16304aaa37f4eba318ae0e085106cfc5502f34148d4d6dfe86d7a000d145e39015ab20471ee812447f16d7b09d60b3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-html (0.2.4)
4
+ rspec-html (0.2.5)
5
5
  nokogiri (~> 1.10)
6
6
  rspec (~> 3.0)
7
7
 
data/README.md CHANGED
@@ -7,7 +7,7 @@ _RSpec::HTML_ provides a simple object interface to HTML responses from [_RSpec
7
7
  Add the gem to your `Gemfile`:
8
8
 
9
9
  ```ruby
10
- gem 'rspec-html', '~> 0.2.4'
10
+ gem 'rspec-html', '~> 0.2.5'
11
11
  ```
12
12
 
13
13
  And rebuild your bundle:
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module HTML
5
- VERSION = '0.2.4'
5
+ VERSION = '0.2.5'
6
6
  end
7
7
  end
@@ -8,8 +8,7 @@ module RSpecHTML
8
8
  extend Forwardable
9
9
 
10
10
  def_delegators :@search,
11
- :has_css?, :has_xpath?, :include?, :present?, :exist?,
12
- :text, :size, :length, :[]
11
+ :has_css?, :has_xpath?, :include?, :text, :truncated_text, :size, :length, :[]
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
@@ -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
 
@@ -1,5 +1,5 @@
1
- <% if actual.element.nil? %>
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.text&.strip || '').inspect %> to contain <%= expected.inspect %> but it did not.
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
4
+ version: 0.2.5
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: 2020-08-17 00:00:00.000000000 Z
11
+ date: 2020-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -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
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  version: '0'
224
224
  requirements: []
225
225
  rubygems_version: 3.1.2
226
- signing_key:
226
+ signing_key:
227
227
  specification_version: 4
228
228
  summary: RSpec HTML
229
229
  test_files: []